by SanyaWaffles » Sat May 30, 2020 1:34 am
I've figured out how to properly do ByteAt based on what you said above.
Code: Select all
String unichar = String.Format("%c", str.ByteAt(currentPos));
seems to be how it's done, with str being whatever string you want to work on.
All the Wiki says about GetNextCodePoint is "(Need more info)". It seems to return two ints. Looking at the source code, it returns the codepoint and the current position.
I tried writing some functions for these:
Code: Select all
String UniCharAt(String str, int pos)
{
String ret = String.Format("%c", str.ByteAt(pos));
Console.PrintF(ret);
return ret;
}
String UniLeft(String str, int len)
{
String find;
for (int i = 0; i < len; i++)
{
find.AppendCharacter(str.GetNextCodePoint(i));
}
Console.PrintF(find);
return find;
}
String UniMid(String str, int pos, int len)
{
String find;
int max = pos + len;
for (int i = pos; i < max; i++)
{
find.AppendCharacter(str.GetNextCodePoint(i));
}
Console.PrintF(find);
return find;
}
I tested it and it seems to work fine, but I'm sure there's some missing checks. I'm still working on the code, but this is a good starting point I think for anyone wanting to explore this.
I've figured out how to properly do ByteAt based on what you said above.
[code]String unichar = String.Format("%c", str.ByteAt(currentPos));[/code]
seems to be how it's done, with str being whatever string you want to work on.
All the Wiki says about GetNextCodePoint is "(Need more info)". It seems to return two ints. Looking at the source code, it returns the codepoint and the current position.
I tried writing some functions for these:
[code]
String UniCharAt(String str, int pos)
{
String ret = String.Format("%c", str.ByteAt(pos));
Console.PrintF(ret);
return ret;
}
String UniLeft(String str, int len)
{
String find;
for (int i = 0; i < len; i++)
{
find.AppendCharacter(str.GetNextCodePoint(i));
}
Console.PrintF(find);
return find;
}
String UniMid(String str, int pos, int len)
{
String find;
int max = pos + len;
for (int i = pos; i < max; i++)
{
find.AppendCharacter(str.GetNextCodePoint(i));
}
Console.PrintF(find);
return find;
}[/code]
I tested it and it seems to work fine, but I'm sure there's some missing checks. I'm still working on the code, but this is a good starting point I think for anyone wanting to explore this.