Sign in Join

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

Mailing lists / fpc-pascal / 2012-11

Re: weird printout of char

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Ewald
to ik: I have a program like this: --------- program print; begin writeln(#$d790); // Should…

Try this: (a char is only one byte, you're trying to print a multi-byte character: print multiple one-byte characters)
WriteLn(#$d7, #$90);

ik wrote 30 lines
Hello, I have a program like this: --------- program print; begin writeln(#$d790); // Should print א end. ---------- I print this to a file: ./program > file In hex editor the value 3F A0 It also the same on normal terminal. I'm using Free Pascal Compiler version 2.6.0 [2012/05/17] for x86_64 Under Linux. What am I missing or doing wrong ? Thanks, Ido _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Ewald Events don't necessarily happen in chronological order; yet somehow they do persist to happen. Sometimes.

Reply by email

ik

Hello,

I have a program like this:

---------
program print;
begin
  writeln(#$d790); // Should print א
end.
----------

I print this to a file:

./program > file

In hex editor the value 3F A0

It also the same on normal terminal.

I'm using Free Pascal Compiler version 2.6.0 [2012/05/17] for x86_64 Under Linux.

What am I missing or doing wrong ?

Thanks,
Ido

Reply by email

Jonas Maebe
to ik
ik wrote 9 lines
I have a program like this: --------- program print; begin writeln(#$d790); // Should print א end. ----------

[snip]

What am I missing or doing wrong ?

a) add "uses cwstring" to get a full unicodestring manager in your program
b) the unicode code point for א is $05d0, not $d790

Jonas

Reply by email

ik
to Jonas Maebe
Jonas Maebe wrote 18 lines
On 05 Nov 2012, at 15:25, ik wrote: I have a program like this: --------- program print; begin writeln(#$d790); // Should print א end. ---------- [snip] What am I missing or doing wrong ? a) add "uses cwstring" to get a full unicodestring manager in your program

When using cwstring, it writes $ED $9E $90 $0A
The Only correct char here is $0A (\n).

b) the unicode code point for א is $05d0, not $d790

I'm trying to use UTF-8, not UTF-16 ($05d0 is UTF-16 values)

Show quoted text 7 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

ik
to Ewald: Try this: (a char is only one byte, you're trying to print a multi-byte character: print…
Ewald wrote
Try this: (a char is only one byte, you're trying to print a multi-byte character: print multiple one-byte characters) WriteLn(#$d7, #$90);

Breaking it into two bytes works.

Show quoted text 43 lines
On 11/05/2012 03:25 PM, ik wrote: > Hello, > > I have a program like this: > > --------- > program print; > begin > writeln(#$d790); // Should print א > end. > ---------- > > I print this to a file: > > ./program > file > > In hex editor the value 3F A0 > > It also the same on normal terminal. > > I'm using Free Pascal Compiler version 2.6.0 [2012/05/17] for x86_64 > Under Linux. > > What am I missing or doing wrong ? > > Thanks, > Ido > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- Ewald Events don't necessarily happen in chronological order; yet somehow they do persist to happen. Sometimes. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to ik: When using cwstring, it writes $ED $9E $90 $0A The Only correct char here is $0A (\n).…

ik wrote on ma, 05 nov 2012:

Show quoted text 11 lines
On Mon, Nov 5, 2012 at 4:39 PM, Jonas Maebe wrote: > > On 05 Nov 2012, at 15:25, ik wrote: > > I have a program like this: > > --------- > program print; > begin > writeln(#$d790); // Should print א

[snip]

I'm trying to use UTF-8, not UTF-16 ($05d0 is UTF-16 values)

#$XXXX means "define a widechar constant with this value", and widechars are always UTF-16. As mentioned in your later mail, if you want to define individual byte values, you have to define them as individual bytes.

Jonas

Reply by email

ik
to Jonas Maebe
Jonas Maebe wrote 25 lines
ik wrote on ma, 05 nov 2012: > On Mon, Nov 5, 2012 at 4:39 PM, Jonas Maebe > wrote: >> >> >> On 05 Nov 2012, at 15:25, ik wrote: >> >> I have a program like this: >> >> --------- >> program print; >> begin >> writeln(#$d790); // Should print א [snip] > I'm trying to use UTF-8, not UTF-16 ($05d0 is UTF-16 values) #$XXXX means "define a widechar constant with this value", and widechars are always UTF-16. As mentioned in your later mail, if you want to define individual byte values, you have to define them as individual bytes.

you are right, sorry.
All work and not enough sleep ... :)

Show quoted text 7 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email