Some ASCII table not working

Bug reports and feature requests. New features can only be added to the current development version. Bug-fixes may be back-ported.

Current release: 099 / Current development: 100
Post Reply
Skinny
Expert Poster
Posts: 76
Joined: Wed Dec 19, 2012 10:27 pm

Some ASCII table not working

Post 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?
Skinny
Expert Poster
Posts: 76
Joined: Wed Dec 19, 2012 10:27 pm

Re: Some ASCII table not working

Post 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
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: Some ASCII table not working

Post 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.
Duttones
Apprentice Poster
Posts: 54
Joined: Tue Mar 27, 2012 8:56 pm

Re: Some ASCII table not working

Post 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
Skinny
Expert Poster
Posts: 76
Joined: Wed Dec 19, 2012 10:27 pm

Re: Some ASCII table not working

Post 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.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Some ASCII table not working

Post 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.
Post Reply