Hi Perloc,
Post by c***@gmail.comThank you for your extended comment!
In your test application above, switch from "PT850" to "PTISO" to see the
text displayed correctly.
I interpreted this as a suggestion.
I've tried to do it but it didn't work.
OK then, it was a suggestion :-) but only one of several tests you
should make in order to familiarize yourself with the codepage concept.
You probably should stay with PT850 in your data and on your screen, but
then we get to the second problem, the codepage in the text editor.
Post by c***@gmail.comYou said: And my point is that you *must* use the same codepage for the
strings in the text editor as you do in the application.
How can I know what code page really is used by the text editor, and the
code page in the application!
I used HB_SetCodePage("PT850 ") in the first place and thought that'll do.
But is seems to be much more complex.
Yes, as I said in my last post, you have to align several different
things regarding codepages to get the correct end result. Codepages have
been discussed a zillion times in this newsgroup, so search it and read
some examples of what has been said previously.
HB_SetCodePage("PT850") tells xHarbour to use that codepage for
everything internally. And I suppose that is what you have in your old
dbf files from Clipper. So as long as you write console applications
with the familiar Clipper look and feel you will be fine.
But - You also have to fix the source code strings to match. You asked
how to know what codepage is used in your Windows based text editors.
The simple answer is: It is a Windows based codepage. Some editors may
allow you to switch to a DOS based codepage (usually called OEM). But
with a Windows editor that will definitely not happen unless you
specifically tell it so. So what you have right now in your editor is
definitely a Windows codepage.
I have never seen the xHarbour builder editor, so I can't say what it
will do. Windows Notepad does not do OEM. NotePad++ might do it, if I
read this web page correctly:
http://docs.notepad-plus-plus.org/index.php/Encodings_And_Character_Display
So try it and see what happens.
There is also a thing called edit.exe (or at least there used to be) in
Windows, a console application that uses an OEM codepage by default. No
fun to use, however.
Post by c***@gmail.comStill I don't know what HB_SetCodePage(" ") does. If in MS-Dos the
code page is set to 850 and you use HB_AnsiToOem("<text>") than the
string is shown as it is in the program.
Please forget about MS-DOS. There is no MS-DOS in the NT family of
Windows versions, although there used to be an *emulation* of MS-DOS for
16-bit applications. That one was called the NTVDM. But I suppose you
mean the Windows console, right?
If you write the string with OEM encoding in a Windows text editor
(possibly using NotePad++ as the web page above seems to suggest) or you
do it in an old 16-bit editor running in the NTVDM - or if you write
the string using a Windows codepage (the default in NotePad++) and then
convert it using HB_AnsiToOem() or any other conversion technique, and
the display is set to PT850 or similar OEM codepage, then it will be
displayed "as you want it to be displayed", not really "as it is". It
will look as if it is "as it is". But it you instead convert it to
hexadecimal, the numbers will be different from those shown in the
editor if you set it tho Hex Edit. Do you follow me? Text that looks the
same is not necessarily identical in terms of the numerical character codes.
Post by c***@gmail.comI've told xHarbour what code page I'm using by HB_Setcodepage("PT850")
but this easy solution didn't work.
No, you have told xHarbour which codepage *it* should use.
Post by c***@gmail.comMr Enrico has told me to use HB_AnsiToOem("<text>") and this works!
But it is a pretty awkward solution
Post by c***@gmail.comBut the code page in MS-Dos must be set to 850 when I use the
Portuguese characters with accents.
I understand well that the code pages from the text editor and the one
used by xHarbour must be the same.
But I cannot see which code page is used by the text editor not by xHarbour..
As I said above, if it is a Windows based text editor, it will use a
Windows codepage. Some editors will allow you to switch to something
else or to convert everything from ANSI and OEM or the other way around
(but the latter can give unexpected results elsewehere in the code).
Post by c***@gmail.comFor me the problem is solved and I can go on with my program.
know all the chr() codes by hart is difficult.
That is definitely not the way to go
Post by c***@gmail.comNow I can easely use the keyboard characters with accents to get it
proper printed on screen.
Take the time to investigate everything about codepages before deciding
on any special handling - like writing every string as an argument to
a conversion function. Time invested now in learning how these things
work will pay off in the future. If you go the wrong route now, you will
regret it in the future when you understand it better.
Regards,
Klas
--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---