amx
amx copied to clipboard
Charset problem
Describe the bug Sometimes in differents part of the code I see a unicode problem.
To reproduce
- Take grandlarc.
- Put this code
- Type in chat something in Unicode
public OnPlayerText(playerid, text[])
{
new pText[144];
format(pText, sizeof (pText), "(%d) %s", playerid, text);
SendPlayerMessageToAll(playerid, pText);
return 0; // ignore the default text and send the custom one
}
Screenshots https://youtu.be/v2sRGcl1AMk
I found a strange behavior.
It works fine when I put first symbol something like !@#$%^&*()-=_
https://translate.google.com/translate?hl=&sl=ru&tl=en&u=https%3A%2F%2Fpro-pawn.ru%2Fshowthread.php%3F13007-%D0%91%D0%B0%D0%B3-%D0%B2-GetPVarString-GetSVarString-%D0%B8-%D0%BA%D0%B0%D0%BA-%D0%B5%D0%B3%D0%BE-%D0%B8%D1%81%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D1%82%D1%8C
https://translate.google.com/translate?sl=ru&tl=en&u=https%3A%2F%2Fpro-pawn.ru%2Fshowthread.php%3F16186
Could anybody check it out?
Judging by the video in the 1'st post, the problem must be in character conversion from char
to cell
- since both types are signed, the conversion is probably done with sign extension, so if a source symbol has a value >= 128
, then all bits in the higher 3 bytes of a cell are set to 1
(so, for example, 0x80
becomes 0xFFFFFF80
instead of 0x00000080
), which is later treated as 3 cyrillic symbols 'я'
being inserted before each source symbol ('я'
has the code FF
). At least that's the bug that most of SA-MP string functions have; kinda funny seeing the same bug being repeated here :)
disinterpreter, can u help me? do u have a fix for this issue?
disinterpreter, can u help me? do u have a fix for this issue?
If the issue is open, so nobody fixed this issue