Sign in Join

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

Mailing lists / fpc-pascal / 2010-09

Question mark?

10 messages · 5 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

In the following program:

{$ Codepage UTF8}
var str: string;
Begin
 Readln (str);
 Writeln (str)
End.

When I enter the following: €uro, shows me: ?uro. The console uses 850 and S.O. 1252, for non-Unicode programs. My question is:
Who puts the question mark?
The widestring manager or my console.

thank you

Jonas Maebe
to Luis Fernando Del Aguila Mejía
Luis Fernando Del Aguila Mejía wrote 14 lines
In the following program: {$ Codepage UTF8} var str: string; Begin Readln (str); Writeln (str) End. When I enter the following: €uro, shows me: ?uro. The console uses 850 and S.O. 1252, for non-Unicode programs. My question is: Who puts the question mark? The widestring manager or my console.

It can be either, but it's probably the widestring manager in this case (it uses a question mark to replace characters that cannot be represented in the current character set; this is detected by the OS' widestring manager returning an error, or in certain cases the the OS' widestring conversion routines themselves will replace unrepresentable characters with '?').

If you are on a Unix platform, remember to add the "cwstring" unit to your uses clause.

Jonas

Luis Fernando Del Aguila Mejía

ok, thanks for your response.
But I believed that the Widestring manager, are routines that are included in the compiled program. But you mention that there is an "OS widestring manager". I'm confused, how many widestring manager exist?.

For example, when I write this statement:
Writeln ('привет'); / / Hello in Russian

The widestring manager, convert the string to six question marks. its ok. But, What Widestring manager, makes the task?.

Thank you.

Jonas Maebe
to Luis Fernando Del Aguila Mejía
Luis Fernando Del Aguila Mejía wrote
ok, thanks for your response. But I believed that the Widestring manager, are routines that are included in the compiled program. But you mention that there is an "OS widestring manager". I'm confused, how many widestring manager exist?.

The widestring manager in the RTL calls through to the OS routines for converting widestrings (except in case you don't use the cwstring unit on Unix platforms; in that case, some default routines in the RTL are used that only support plain ASCII).

Jonas

Luis Fernando Del Aguila Mejía

Ok, I understand.
So readln is affected by the WideString Manager, and the WideString Manager use operating system routines, (Windows). In linux I use cwstring. ok.

In this case, When I use readln. readln (cad);
The command interpreter uses 850 (cmd), but Windows uses 1252. When I enter the symbol €, it converts it to ?. As I understand, because this symbol does not exist in 850.
But when I use Writeln ('€'), no shows the question mark ?. As I understand, it is because the symbol exists in 1252.

That is, When I use readln, then the Widestring manager use the charset of the command interpreter (cmd 850), and when I use writeln, then the Widestring manager, use the charset of the Operating System (ANSI-1252). (only windows)

Am I right, or am I wrong?

thanks

Jonas Maebe
to Luis Fernando Del Aguila Mejía
Luis Fernando Del Aguila Mejía wrote 6 lines
That is, When I use readln, then the Widestring manager use the charset of the command interpreter (cmd 850), and when I use writeln, then the Widestring manager, use the charset of the Operating System (ANSI-1252). (only windows) Am I right, or am I wrong?

I don't know the details of how it works under Windows.

Jonas

Marco van de Voort
to Jonas Maebe

In our previous episode, Jonas Maebe said:

Show quoted text 10 lines
On 11 Sep 2010, at 20:54, Luis Fernando Del Aguila Mej?a wrote: > That is, When I use readln, then the Widestring manager use the charset of > the command interpreter (cmd 850), and when I use writeln, then the > Widestring manager, use the charset of the Operating System (ANSI-1252). > (only windows) > > Am I right, or am I wrong? I don't know the details of how it works under Windows.

More or less yes. The cmdline interpreter uses a different (labelled OEM, generally more doslike) charset, then the Windows system charset (Windows-xx, refered to in windows api as "ANSI")

Searching for OEM in Mantis yields some of the known problems with this, namely 14467,15233,16064. Our current model does not properly model this as far as I can see.

Luis Fernando Del Aguila Mejía

ok, I understand.

Excuse my ignorance. But what is mantis?
What routines of the Windows API, use the Widestring Manager in Windows? Is there a guide to understanding the source of FPC?

Thank you.
Danke.