0

I am having an issue where on linux my characters like łąćźżó are not displayed correctly (like (TM)`~řÉ), but on windows they are, with the same code.

int main()
{ 
    printf("łąć");
    return 0;
}

this displays correctly when compiled on windows but not on linux, but I even added the utf-8 options and saved all files as UTF-8 encoding :(

Makefile flags only + link:

COMPILE_FLAGS = -std=c++0x -m32 -fPIC -c -finput-charset=UTF-8 -finput-charset=UTF-8 -fwide-exec-charset=UTF-8 -I ./ -w -D LINUX -D PROJECT_NAME=\"SampCaptcha\"

SampCaptcha = -D SampCaptcha $(COMPILE_FLAGS)

$(GPP) -m32 -lrt -ldl -fshort-wchar -shared -o $(SampCaptcha_OUTFILE) *.o

Why is this not working? the text is unreadable to users this way.

Alright, so people are asking for the 1:1 input/output, here you go:

Output on linux: enter image description here

and this is the text:

Message("Witaj nowy graczu!");
Message("Wygląda na to iż Twoje ip nie jest nam znane");
Message("Za chwilkę zostaniesz przekierowany na serwer i będzies spokojnie mógł grać z innymi");
Message("Zanim to jednak zrobimy, pierwszę sprawdzimy czy nie jesteś komputerem który chce zepsuć serwer");
Message("Proszę się zrespawnować aby kontynuować");

And like I said, when compiled as a DLL it works on Windows, when inputting directly commands into the host program with unicode characters they are displayed on the chat. (it's a closed source application anyway to which I don't have access, but we are sure it's my GCC doing something wrong, many other people seem to have no problems with displaying special characters)

output of locale:

~# locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
Gizmo
  • 1,990
  • 1
  • 24
  • 50
  • Don't have much experience working with UTF-8 but found [this](http://stackoverflow.com/questions/15528359/printing-utf-8-strings-with-printf-wide-vs-multibyte-string-literals) Seems to be along the same lines of your question so hope that helps. – James H Nov 21 '14 at 06:34
  • what's your output on linux? – AliciaBytes Nov 21 '14 at 06:46
  • hm already a downvote, seems like migrating from windows to linux won't be an option -.-' – Gizmo Nov 21 '14 at 06:55
  • Maybe your `Message()` function is doing something wrong? I can't reproduce it, prints correctly with `printf()` on my ubuntu machine: http://i.stack.imgur.com/HgSVf.png – AliciaBytes Nov 21 '14 at 07:05
  • hm I will consult the people that created the software in that case, I thought it was my G++/GCC. – Gizmo Nov 21 '14 at 07:45
  • Is your terminal capable of UTF-8 output? What happens if you `cat yourfilename.c`? Also show the output of `locale` command. – n. m. could be an AI Nov 21 '14 at 08:12
  • Also before blaming gcc or Linux try a [known good system](http://ideone.com/1ZJc1m). – n. m. could be an AI Nov 21 '14 at 08:19
  • when I `cat GameMode.cpp` I get to see the file which has the correct characters. – Gizmo Nov 21 '14 at 09:27
  • @n.m. that known good system has been configured by people who know how GCC works on all fronts and work on a dayly basis with it – Gizmo Nov 21 '14 at 09:29
  • Your system is configured correctly out of the box. You may want to (1) remove the -fwide-exec-charset option (it is wrong to set it to UTF-8, it should be UTF-32 which is the default anyway) and (2) at the start of the program, call `setlocale(LC_ALL,"")` which you should do in most programs anyway, but these should not affect the result of this particular prrogram. What terminal are you using? What happens if you do `printf '\xc5\x81\xc5\x82\n'` in the terminaal? – n. m. could be an AI Nov 21 '14 at 12:40

0 Answers0