- added CharUpper and CharLower functions to ZScript.

These, like MakeUpper and MakeLower, use the internal Unicode case conversion tables.
This commit is contained in:
Christoph Oelckers 2019-04-13 10:26:55 +02:00
parent f7561f25d6
commit 3938119192
2 changed files with 28 additions and 0 deletions

View file

@ -50,6 +50,7 @@
#include "am_map.h"
#include "v_video.h"
#include "gi.h"
#include "fontinternals.h"
#include "intermission/intermission.h"
DVector2 AM_GetPosition();
@ -285,6 +286,31 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, MakeLower, StringMakeLower)
ACTION_RETURN_STRING(self->MakeLower());
}
static int StringCharUpper(int ch)
{
return ch >= 0 && ch < 65536 ? upperforlower[ch] : ch;
}
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, CharUpper, StringCharUpper)
{
PARAM_PROLOGUE;
PARAM_INT(ch);
ACTION_RETURN_INT(StringCharUpper(ch));
}
static int StringCharLower(int ch)
{
return ch >= 0 && ch < 65536 ? lowerforupper[ch] : ch;
}
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, CharLower, StringCharLower)
{
PARAM_PROLOGUE;
PARAM_INT(ch);
ACTION_RETURN_INT(StringCharLower(ch));
}
static int StringToInt(FString *self, int base)
{
return (int)self->ToLong(base);

View file

@ -909,6 +909,8 @@ struct StringStruct native
deprecated("4.1") native void ToLower();
native String MakeUpper();
native String MakeLower();
native static int CharUpper(int ch);
native static int CharLower(int ch);
native int ToInt(int base = 0) const;
native double ToDouble() const;
native void Split(out Array<String> tokens, String delimiter, EmptyTokenType keepEmpty = TOK_KEEPEMPTY) const;