1. console charset

I have an entry level question. :-> Whenever I print something onto the screen some special characters are not readable for me. E.g.

puts(1,"Helló világ!") -- means "Hello world" in Hungarian 
 

would appear incorrectly due to the "ó" and "á" characters. I suppose it is because of the codepage differences. But is there a simple way of defining that the script I saved in UTF-8 should print to the console/command line the text as ibm852 charset? I'm equally interested in Win and Linux solution...

Thanks for any tips/hints/ideas in advance!

Salix

new topic     » topic index » view message » categorize

2. Re: console charset

Salix said...

I have an entry level question. :-> Whenever I print something onto the screen some special characters are not readable for me. E.g.

puts(1,"Helló világ!") -- means "Hello world" in Hungarian 
 

would appear incorrectly due to the "ó" and "á" characters. I suppose it is because of the codepage differences. But is there a simple way of defining that the script I saved in UTF-8 should print to the console/command line the text as ibm852 charset? I'm equally interested in Win and Linux solution...

Thanks for any tips/hints/ideas in advance!

Salix

Not really. Euphoria right now doesn't handle charset conversion at all, it just reads whats in the text file and spits it out raw.

On Unix, you can replace

puts(1,"Helló világ!") -- means "Hello world" in Hungarian 

with

system("echo -n 'Helló világ!' | iconv -t ibm852 -f utf8") -- means "Hello world" in Hungarian 

assuming your console/xterm/etc is set up to use ibm852 as the console charset. (My xterms/Terminals are set up to use UTF-8 as the charset.)

iconv has been ported to Windows (Mingw has a iconv.exe I believe), so if you can't find a better option, at least you have something portable...

new topic     » goto parent     » topic index » view message » categorize

3. Re: console charset

Salix said...

I have an entry level question. :-> Whenever I print something onto the screen some special characters are not readable for me. E.g.

puts(1,"Helló világ!") -- means "Hello world" in Hungarian 
 

would appear incorrectly due to the "ó" and "á" characters. I suppose it is because of the codepage differences. But is there a simple way of defining that the script I saved in UTF-8 should print to the console/command line the text as ibm852 charset? I'm equally interested in Win and Linux solution...

Thanks for any tips/hints/ideas in advance!

Salix

On windows there two simple Win32 API functions to convert from/to OEM
CharToOem() http://msdn.microsoft.com/en-us/library/ms647473%28VS.85%29.aspx
OemToChar() http://msdn.microsoft.com/en-us/library/ms647493%28VS.85%29.aspx

This convert from windows codepage to console codepage or the opposite

Jacques

new topic     » goto parent     » topic index » view message » categorize

4. Re: console charset

Salix said...

I have an entry level question. :-> Whenever I print something onto the screen some special characters are not readable for me. E.g.

puts(1,"Helló világ!") -- means "Hello world" in Hungarian 
 

would appear incorrectly due to the "ó" and "á" characters. I suppose it is because of the codepage differences. But is there a simple way of defining that the script I saved in UTF-8 should print to the console/command line the text as ibm852 charset? I'm equally interested in Win and Linux solution...

Thanks for any tips/hints/ideas in advance!

Salix

I have some solutions displaying local characters in Windows. All the following I've tested successfully on my Win Vista Home Basic Russian sp2 using 1251, 866, 1250 and 852 code-pages (all my attempts with UTF-8 failed)

You have to check the encoding of your euphoria script and make it matched with your local windows console encoding.

Solution 1. Force the console to use the codepage of your script with following.

chcp [your code page number] 

or make it from the EU script

system_exec("chcp [your code page number]", 2) 

Solution 2. If you writing console app, just write it with your default console code-page, so it'll be ready for your charset from start.

Your case.
I believe you have to convert your euphoria script into Hungarian code-page (not to UTF):

  • into Hungarian for win gui - 1250
  • or into Hungarian for win console - 852

If you convert it to code-page 852, your work is done. If you convert it to code-page 1250 you have to change your script with following:

system_exec("chcp 1250", 2) 
puts(1,"Helló világ!") -- means "Hello world" in Hungarian 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu