Page 1 of 1

Some ASCII table not working

Posted: Tue Jan 03, 2017 6:49 am
by Skinny
Hi.

Using POL on Linux, when i try do use some special character, for example "ç" or "á" in bc.src (bc.ecl) textcmd, the pol isn't recognizing and always show as "?" character (63 decimal ASCII table).

See the bc.src file:

Code: Select all

use unicode;

program textcmd_bcast( who, text )
    BroadcastUC(CAscZ("ç - " + text), "ENU", 0, 55);
    Print(CAscZ(text));
endprogram
When i write in-game the command:

Code: Select all

.bc aá
the output script in-game is:

Code: Select all

ç - a?
the console output POL script:

Code: Select all

{ 97, 63 }
So, the character "á" is 225 ASCII code, but the POL only recongnize as "?" (63 ASCII code).
The script is already in ASCII mode with notepad++.
I've tested on Windows and this problem isn't occur.
But on Linux (Debian), this problem occur.

Anyone can help?

Re: Some ASCII table not working

Posted: Tue Jan 03, 2017 7:31 am
by Skinny
The solution: https://docs.polserver.com/pol099/scrip ... mandScript

Thanks Nando for solve the problem.

Code: Select all

use unicode;

program textcmd_bcast(who, text, uc_text, langcode)
    BroadcastUC(CAscZ("- ") + uc_text, "ENU", 0, 55);
endprogram

Re: Some ASCII table not working

Posted: Tue Jan 03, 2017 9:59 am
by Nando
For posterity: the conversion from wide-char (unicode) to byte (ascii) is performed by basic_ios::narrow(). This only works when the computer's locale can represent that unicode character as a single byte, otherwise a "?" is used. That would explain the difference between Windows and Linux.

Using uc_text, as above, is a more robust solution. The same may happen in NPC or Item speech events.

Re: Some ASCII table not working

Posted: Sun Dec 24, 2017 11:17 pm
by Duttones
Skinny, did you had a permanent solution that doesn`t use the uc_text parameter? Update everything now will get me an hell of a headache.

I already tried to update the locale of Ubuntu, but nothing seems to work for POL.

LANG=pt_BR.iso88591
LANGUAGE=pt_BR:pt:en
LC_CTYPE="pt_BR.iso88591"
LC_NUMERIC="pt_BR.iso88591"
LC_TIME="pt_BR.iso88591"
LC_COLLATE="pt_BR.iso88591"
LC_MONETARY="pt_BR.iso88591"
LC_MESSAGES="pt_BR.iso88591"
LC_PAPER="pt_BR.iso88591"
LC_NAME="pt_BR.iso88591"
LC_ADDRESS="pt_BR.iso88591"
LC_TELEPHONE="pt_BR.iso88591"
LC_MEASUREMENT="pt_BR.iso88591"
LC_IDENTIFICATION="pt_BR.iso88591"
LC_ALL=

System Locale: LANG=pt_BR.iso88591
LANGUAGE=pt_BR:pt:en
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105

Re: Some ASCII table not working

Posted: Tue Dec 26, 2017 5:40 pm
by Skinny
Duttones wrote: Sun Dec 24, 2017 11:17 pm Skinny, did you had a permanent solution that doesn`t use the uc_text parameter? Update everything now will get me an hell of a headache.
No, Duttones. Only this, unfortunately.

Re: Some ASCII table not working

Posted: Wed Dec 27, 2017 2:18 am
by Turley
A potential fix could be to replace the current

Code: Select all

setlocale( LC_TIME, "" );
In clib/Program/ProgramMain.cpp
With

Code: Select all

std::setlocale(LC_ALL, "");
std::setlocale(LC_NUMERIC, "C");
std::locale::global(std::locale(std::locale(""), std::locale("C"), std::locale::numeric));
std::cout.imbue(std::locale());
And as additional header on top:

Code: Select all

#include <locale>
Since I'm unaware of the potential side effects and I currently cannot test it, I would be pleased if someone can test and report.