I have to type in UTF-8 code rather than words
-
If I just type in words, it will not display correctly in GTA5. However, if I type in UTF-8 code, it will.
The place where I type in is a .ini file which is encoded in UTF-8.I suspect that when typing in Chinese words in Notepad++, Notepad++ do not encode them in UTF-8 code.
Is my guess true? How can I resolve it?
-
@hadock987 said in I have to type in UTF-8 code rather than words:
I suspect that when typing in Chinese words in Notepad++, Notepad++ do not encode them in UTF-8 code.
Is my guess true? How can I resolve it?I suspect you’re wrong. It’s really easy to check: the status bar on the bottom of Notepad++ will show whether or not it is editing in UTF-8 mode.
[somesection] HoldToSpawn = 按住~y~Backspace~s~來讓~b~
D:\Users\Peter\Downloads\NppCommunity>xxd uni.ini 00000000: 5b73 6f6d 6573 6563 7469 6f6e 5d0d 0a48 [somesection]..H 00000010: 6f6c 6454 6f53 7061 776e 203d 20e6 8c89 oldToSpawn = ... 00000020: e4bd 8f7e 797e 4261 636b 7370 6163 657e ...~y~Backspace~ 00000030: 737e e4be 86e8 ae93 7e62 7e0d 0a s~......~b~..
The e68c89 is the UTF-8 3-byte encoding for the one you have shown as
按
in the later example, so Notepad++ is doing the right thing with Unicode characters properly entered when Notepad++ believes it is in UTF-8 mode.Though I just realized: do you think that typing按
in Notepad++ will save the unicode character按
in the bytes of the ini file? If you think that, you are sorely mistaken. Notepad++ saves the characters you type. And unlike HTML/XML, Notepad++ doesn’t translate XML/HTML entities into their actual characters when you save or display the file. So if your ini is really[somesection] HoldToSpawn=按住~y~Backspace~s~來讓~b~...
Then you are getting exactly what you should: you typed a bunch of ascii characters, including ampersand, number sign, ex, six, three, zero, nine, semicolon, and that’s what your game is seeing.looking again at your post, where you compare the failing screenshot with extra box bytes in the top screenshot, compared to the one below which seems to be correct where you give it enties, maybe you really did type the Chinese characters in the first example. So I crossed out the entity paragraph.
If your game isn’t really expecting the .ini file to be in UTF-8, or if it only believes it is UTF-8 if it has the BOM, you may need to change to Encoding > UTF-8-BOM instead of Encoding > UTF-8 to better convince your game to process the .ini file as UTF-8.
So, to sum up: most likely, either you don’t actually have Notepad++ editing in UTF-8 mode (in which case, you just need to change the encoding in Notepad++), or your game doesn’t recognize an .ini file as UTF-8 without the BOM (in which case, you need to change to UTF-8-BOM in Notepad++ so it saves the BOM character), or your game doesn’t accept UTF-8 for the .ini, despite your assertion that it does.