Jump to content

need more string functions


photo

Recommended Posts

I've suggested this in mail support system, but it seems no reply, I need more string functions, mainly for utf8 and locale string conversion.

 

We know that UI and widgets are all use utf8, but the function engine.app.setTitle can not use utf8, if I use this function in world script and use some chinese as title, save the script as utf8, the title just appears as non-recognized text.(because this string must not be encoded as utf8)

 

If i save this world script as system default locale, such as cp936( or ascii ), and I set some text of widgets, like label, window widget's title, it also shows nothing(because these text is not encoded as utf8)

 

This situation happened in every scene of my project.. :D

 

I think if there is some function to convert multi-byte string to utf8 and would be very happy to the asia clients. I've seen there are some functions like

static int utf8ToUnicode(const char *src,wchar_t &code);
static int utf8ToUnicode(const char *src,wchar_t *dest,int size);

static int utf8strlen(const char *str);
static StringStack utf8substr(const char *str,int pos,int len = -1);

but why these functions do not exist in the script engine?

Link to comment

engine.app.getTitle() will support strings in utf8 format next update.

 

utf8strlen() and utf8substr() should be available in Unigine script already.

 

I will add utf8ToUnicode() and unicodeToUtf8() functions in script also.

Link to comment

so if engine.app.getTitle support utf8, then all the script file and ui file are all utf8 encoded?

 

and the whole unigine's text file's like material and properties files are all utf8 encoded?

 

 

If that's true, we will be very happy :D :lol: :lol: :lol:

Link to comment

so if engine.app.getTitle support utf8, then all the script file and ui file are all utf8 encoded?

 

and the whole unigine's text file's like material and properties files are all utf8 encoded?

 

 

If that's true, we will be very happy :D :lol: :lol: :lol:

 

All of Unigine resources (materials, properties, textures, meshes, scripts, ui files) should work in utf8 encoding correctly.

Different behaviour is treated as bug.

Link to comment

This functions will be available in next update.

 

int unicode[0];
utf8ToUnicode("日本語",unicode);
string result = unicodeToUtf8(unicode);
forloop(int i = 0; unicode.size()) {
 printf("%d: %d\n",i,unicode[i]);
}
printf("%s\n",result);

 

0: 26085

1: 26412

2: 35486

3: 0

日本語

Link to comment

well, in your example, the script file must be saved as utf-8 right?

 

if not saved in utf-8 mode, the utf8ToUnicode function will convert to wrong string.

 

So, if engine.app.setTitle support utf8, there might be more functions need to support utf8, like engine.message, log.message,

 

if these functions don't support utf8 string, then every asia characters must be converted with unicodeToUtf8 and the script file must be saved as utf16, then here comes another problem, how can I represent the unicode string? using this?

int unicode[]=('中', '文');

 

that will be a big problem.

 

so I mean either of this,

1) add a function like multibyteToUtf8 and utf8ToMultibyte, not just unicodeToUtf8

or 2) make every (might not need every function) string function utf8 aware, so that every resource file can be directly saved as utf8.

Link to comment
×
×
  • Create New...