Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-02

Ido not understand UTF8 in Windows console.

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Fernando Del Aguila Mejía

Translate Message : English
Ido not understand UTF8 in Windows console.
I wrote the following program, using an editor UTF8 without BOM mark.

{código de página UTF8}
//sin firma Unicode BOM
Begin
 Writeln('code page UTF8 - 65001 en Windows');
 Writeln('camión')
End.

Using the command chcp, change the code page to 65001, the UTF-8 for Windows. I compiled the program, and then run and get the following errror: Runtime error 101 at $00401460
$00401460
$004069B1

The same program when compiled and run on linux, no error. works well. What am I doing wrong?

Original Message Spanish:
No entiendo UTF8 en consola Windows
Yo escribí el siguiente programa, usando un editor UTF8, sin marca de BOM. Usando el comando chcp, cambio el código de página a 65001, el UTF8 para Windows. Compilo el programa, y después lo ejecuto y aparece el siguiente error :
El mismo programa, cuando lo compilo y lo ejecuto en linux, no aparece ningún error. funciona bien.
¿Qué estoy haciendo mal?

Reply by email

JoshyFun
to Luis Fernando Del Aguila Mejía

Hello FPC-Pascal,

Wednesday, February 17, 2010, 10:46:18 PM, you wrote:

LFDAM> {código de página UTF8}
LFDAM> //sin firma Unicode BOM
LFDAM> Begin
LFDAM> Writeln('code page UTF8 - 65001 en Windows'); LFDAM> Writeln('camión')
LFDAM> End.
LFDAM> Using the command chcp, change the code page to 65001, the UTF-8 for LFDAM> Windows. I compiled the program, and then run and get the following errror: LFDAM> Runtime error 101 at $00401460
LFDAM> $00401460
LFDAM> $004069B1

If you are doing this in Lazarus by default you are creating a GUI application, so any writeln will raise an error as stdout is closed.

LFDAM> The same program when compiled and run on linux, no error. works well. LFDAM> What am I doing wrong?

Linux always have a stdout open.

LFDAM> Original Message Spanish:
LFDAM> No entiendo UTF8 en consola Windows
LFDAM> Yo escribí el siguiente programa, usando un editor UTF8, sin marca de BOM. LFDAM> Usando el comando chcp, cambio el código de página a 65001, el UTF8 para LFDAM> Windows. Compilo el programa, y después lo ejecuto y aparece el siguiente LFDAM> error :
LFDAM> El mismo programa, cuando lo compilo y lo ejecuto en linux, no aparece LFDAM> ningún error. funciona bien.
LFDAM> ¿Qué estoy haciendo mal?

Lo mismo pero en español :) Vamos que elimines el flag de "Win32 GUI application" en Compiler -> Linker.

Por cierto CP_UTF8 sólo funciona en >=NT 4.0 con fuentes TrueType en ventana y muchos bats y similares dejan de funcionar.

Best regards, JoshyFun

Reply by email

Luis Fernando Del Aguila Mejía
If you are doing this in Lazarus by default you are creating a GUI application, so any writeln will raise an error as stdout is closed.

I am not using lazarus, I am using PSPad, gedit, jedit, notepad, etc.. I just wanted to know is whether you can write the source code using UTF8. In linux this simple program, it compiles and runs, but in windows vista bussines is not possible.
The problem appears only when using UTF8 own characters, like accented "o".

Example: "camión", with accent at failure, but "camion" without an accent, not the failure occurs

Reply by email

JoshyFun
to Luis Fernando Del Aguila Mejía

Hello FPC-Pascal,

Thursday, February 18, 2010, 7:05:44 PM, you wrote:

LFDAM> I am not using lazarus, I am using PSPad, gedit, jedit, notepad, etc.. LFDAM> I just wanted to know is whether you can write the source code using UTF8. LFDAM> In linux this simple program, it compiles and runs, but in windows vista LFDAM> bussines is not possible.
LFDAM> The problem appears only when using UTF8 own LFDAM> characters, like accented "o".
LFDAM> Example: "camión", with accent at failure, but "camion" without an accent, LFDAM> not the failure occurs

I had tested it in every combination that crossed my mind, with BOM, without BOM, in ANSI, and never found the 101 error :-? Using fpc 2.5.1

I'm using WinXP SP3 so Vista can have a different behavior...[tested the exe generated in my WinXP in a Vista and no error and no accented "o" shown using chcp 65001].

Sources can be compiled in fpc using UTF8 sources. Remember that most linux have a default ANSI charset UTF8 while windows uses code page.

If you like put an attached small file to be compiled directly and the command line to be used and I'll test it.

Best regards, JoshyFun

Reply by email