Discussion:
Function HB_SetCodePäge("PT850") won't work
(too old to reply)
c***@gmail.com
2015-10-14 09:59:09 UTC
Permalink
Hello programmers,

I need for Portuguese accents code page 850
When I put:
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
in mij program the coed page remains stuborn on EN and:
? @10,10 say "Coração"
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.

What's wrong?
perloc
dlzc
2015-10-14 14:23:09 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
in mij program the coed page remains stuborn on
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
Did you
REQUEST PT850
... at the top of your program, before executable statements?

From the online docs:
REQUEST HB_CODEPAGE_DEWIN && <<HB_CODEPAGE_PT850

PROCEDURE Main
...
HB_SetCodePage( "DEWIN" ) && <<HB_CODEPAGE_PT85o

... and you'd make the substitutions from this entry in the online docs:
Portuguese 850 HB_CODEPAGE_PT850 "c" cppt850.c
... as I noted above.

Maybe that will help?

David A. Smith
c***@gmail.com
2015-10-14 14:39:11 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Thanks for your answer!
This is what I want to reach:
****************************
Request HB_CodePage_PT850
Procedure main

// Setup code page portuguese 850

Clear

HB_SetCodePage()
HB_SetCodePage("PT850")

@ 10,10 say "Coração"

Return
**************

The characters with accents from Coração (hart) presented (after compiling and run) are not the ones in my program.

perloc
dlzc
2015-10-15 02:30:59 UTC
Permalink
Post by c***@gmail.com
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Thanks for your answer!
****************************
Request HB_CodePage_PT850
Procedure main
// Setup code page portuguese 850
Clear
HB_SetCodePage()
HB_SetCodePage("PT850")
@ 10,10 say "Coração"
Return
**************
The characters with accents from Coração (hart)
presented (after compiling and run) are not the
ones in my program.
Are you running one of the wvw or wvt graphics? If so:
https://groups.google.com/d/msg/comp.lang.xharbour/9fQ43je7Tp4/L3bivQpK4RsJ

David A. Smith
c***@gmail.com
2015-10-15 03:36:46 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Hello mr David, good day to you!

I don't know what wvw- or wvt graphics is, so I suppose that I do not run it.
I tried the suggestion of ***@gmail.com but it won 't work.
The function HB_CDPselect() is not listed in the doc, but is accepted.
perloc
dlzc
2015-10-15 14:23:04 UTC
Permalink
Dear cvan...:

On Wednesday, October 14, 2015 at 8:36:51 PM UTC-7, ***@gmail.com wrote:
...
Post by c***@gmail.com
I don't know what wvw- or wvt graphics is, so I
suppose that I do not run it. I tried the
The function HB_CDPselect() is not listed in the doc,
It is valid / defined in wvw- and wvt- graphics. So if you do not link them into your program, then it willnot work.
Post by c***@gmail.com
but is accepted.
Should have produced an error.

I moved to a new machine, and I compiled my code over and over, but since I had a slightly different drive setup, I never got any .EXE output. So my last suggestion, is to make sure the .PRG you have this REQUEST in is in the directory you start compiling from, to recompile your executable, force it to compile all sources, and make sure that the file date is updated on the produced executable. If not, then your scripting is not working.

Beyond this, I am not really helping. Are you current on your xHarbour version? Does Windoze otherwise display this font correctly (in other applications, I think you already said it does)?

David A. Smith
c***@gmail.com
2015-10-15 17:27:27 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Dear Mr. David,

I don't use any grafics in my program.
The example I've given between the 2 star bars is a standalone,
but used in a much bigger program.
*************************
Request HB_CodePage_PT850
Procedure main

// Setup code page portuguese 850

Clear

HB_SetCodePage()
HB_SetCodePage("PT850")

@ 10,10 say "Coração"

Return
*************************
If I compile and run this program the text "Coração" is displayed as "CoraþÒo"

Moreover, I don't know what WVW and WVT grafics is.
Is this used in the Clipper language?
And how can I add this in my program?

HB_CDPselect() don't give an error during compiling but it is not listed in the
xHarbour Language Reference Guide.chm

perloc
dlzc
2015-10-15 19:56:32 UTC
Permalink
Dear cvan...:

On Thursday, October 15, 2015 at 10:27:29 AM UTC-7, ***@gmail.com wrote:
...
Post by c***@gmail.com
I don't use any grafics in my program.
If you link in the library, whether you use the graphics or not, you have to use HB_CDPselect(). You have said this did not work, so it does not matter.

...
Post by c***@gmail.com
If I compile and run this program the text "Coração"
is displayed as "CoraþÒo"
OK, so either the xHarbour table is faulty, pointed at the wrong characters, or the font is not installed in that Windoze.
Post by c***@gmail.com
Moreover, I don't know what WVW and WVT grafics is.
Is this used in the Clipper language?
Clipper- no. (x)Harbour- yes.
Post by c***@gmail.com
And how can I add this in my program?
I do not know that you would want to do this, or that this would help.
Post by c***@gmail.com
HB_CDPselect() don't give an error during compiling
but it is not listed in the xHarbour Language
Reference Guide.chm
Understood. Documented in wvw- and wvt- docs, presumably. But since it doesn't work, it is not an issue.

Please forget wvw- or wvt- graphics for now. Had you been using them, they required a different way to change the code page. Since you are not using them, please forget this.

So I will just ask you again, to assure that your new code with the REQUEST, is used to make your current executable. If it is, then I have no more advice.

Someone else will have to chime in, if they see a different result than you.

David A. Smith
Klas Engwall
2015-10-17 18:08:39 UTC
Permalink
Hi Perloc,
Post by c***@gmail.com
Request HB_CodePage_PT850
Procedure main
// Setup code page portuguese 850
Clear
HB_SetCodePage()
HB_SetCodePage("PT850")
@ 10,10 say "Coração"
Return
*************************
If I compile and run this program the text "Coração" is displayed as "CoraþÒo"
That is how it will be displayed if you have *written* the program using
a Windows based codepage in the text editor and you then tell (x)Harbour
to *display* the text using a DOS based codepage (PT850) in the
application. You have to use the same character set in both places.

In your test application above, switch from "PT850" to "PTISO" to see
the text displayed correctly. But I suspect that your current data files
are in PT850 format. If so, then you should probably keep "PT850" and
switch the editor to DOS mode (or use a different editor that
understands the DOS character set).

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
c***@gmail.com
2015-10-16 03:16:57 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
OK Mr. David,

Thanks a lot for your attention!

I would like to know if somebody else is using this function HB_SetCodePage("....").
And if he/she can give me an advice.

perloc
Gerard de Vries
2015-10-16 10:50:30 UTC
Permalink
Hi,

A while ago I struggled with displaying characters that are in codepage 1252
properly on screen. Also, I wanted them stored properly in our SQL database.
In the end, the only option for me was to use GTWVW and use the setting:

WVW_SetCodePage(, 1)

I had no luck with HB_SetCodePage(..)

With GTWVW and the setting above, all the characters in codepage 1252 are
handled properly on screen and in the database. I'm not sure if this would
be an option to you, since some of the special Portuguese characters might
not be in the 1252 codepage.

Kind regards,

Gerard
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
OK Mr. David,

Thanks a lot for your attention!

I would like to know if somebody else is using this function
HB_SetCodePage("....").
And if he/she can give me an advice.

perloc
c***@gmail.com
2015-10-17 14:12:33 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Dear Mr. Gerard,

I'm sorry but this is not usable for me.
It should be in the Extended Clipper language of xHarbour.
On the other hand it also could not be of use because the characters, to make boxes, are missing. The letters with accents, needed for me, are present.

By the way, are you Dutch?

Thanks for your answer,

Cees van Perlo
c***@gmail.com
2015-10-18 04:02:24 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Hi Klas,

It isn't that easy as you suggest.
My code page in MS-DOS is permanently set to page 850.
This means that PTISO don't work.
The above is only an example what's wrong.
In my big program I also have for MS-DOS "Run chcp 850" to be shure that the code page is adjusted to 850.

I don't know what codepage is set when I run the program.
I have a booklet with only the code pages in the 800 series and the characters in the printed word "CoraþÒo" are not found for the letters çã.

Finally, I use several different editors as there are Notepad++, the editor delivered by xHarbour Builder and Notepad from Windows.
It makes no difference.
The characters with accents I type in my program are by setting:
Control Panel\
Region and language\
Keyboards and Languages\
Hit Change keyboards
and use English (US) keyboard - United States International.

perloc
Enrico Maria Giordano
2015-10-18 08:28:40 UTC
Permalink
The following sample

FUNCTION MAIN()

HB_SETCODEPAGE( "PT850" )

? SET( _SET_CODEPAGE )

? "Coração"

INKEY( 0 )

RETURN NIL

prints

EN
CoraþÒo

What am I missing?

I've already tried with other languages and REQUEST. Same result.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
danca (Daniele Campagna)
2015-10-18 14:13:24 UTC
Permalink
Post by c***@gmail.com
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Hi Klas,
It isn't that easy as you suggest.
My code page in MS-DOS is permanently set to page 850.
This means that PTISO don't work.
<etc>
I'm not sure you got the point. Text editors rarely save the text files
in truly dos mode, with the ascii characters following CP850.

So when you write in your program "@ x,y say <string with national
characters>, the ASCII file is written with the <string with national
characters> codified usually with a Windows codepage, and the compiled
program has instead different ASCII codes for the national characters,
so on the screen you get a wrong string.

Dan
--
"Everybody should pay taxes with a smile"
I tried, but they want money.
Enrico Maria Giordano
2015-10-18 14:32:20 UTC
Permalink
This is working:

FUNCTION MAIN()

? "Coração"

? HB_ANSITOOEM( "Coração" )

INKEY( 0 )

RETURN NIL

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-18 18:03:09 UTC
Permalink
Hi Perloc,
Post by c***@gmail.com
It isn't that easy as you suggest.
I have not suggested anything for your real application. As Daniele
said, neither you nor Enrico really got the point I was trying to make.
And my point is that you *must* use the same codepage for the strings in
the text editor as you do in the application.
Post by c***@gmail.com
My code page in MS-DOS is permanently set to page 850.
This means that PTISO don't work.
But you are using Windows, not MS-DOS. Your old Clipper applications run
in the NTVDM, which is an MS-DOS emulator that uses MS-DOS based
codepages by default. But your new xHarbour applications run in Windows,
and that is a different world. You have to tell xHarbour which codepage
to use, and you have to be consistent with your choice of codepage.
Mixing Windows text in the source code with DOS output (an 850 or 437
codepage) in the application is not going to work.
Post by c***@gmail.com
The above is only an example what's wrong.
In my big program I also have for MS-DOS "Run chcp 850" to be shure that the
code pageis adjusted to 850.
And that makes no difference for the xHarbour applications.
Post by c***@gmail.com
I don't know what codepage is set when I run the program.
Yes you do. You tell xHarbour which codepage to use with the
HB_SetCodePage() function.
Post by c***@gmail.com
I have a booklet with only the code pages in the 800 series and the characters
in the printed word "CoraþÒo" are not found for the letters çã.
Finally, I use several different editors as there are Notepad++, the editor
delivered by xHarbour Builder and Notepad from Windows.
So you use a Windows programming editor (any/all of those) and you tell
xHarbour to display your strings with a DOS codepage. That is where it
goes wrong.
Post by c***@gmail.com
It makes no difference.
Control Panel\
Region and language\
Keyboards and Languages\
Hit Change keyboards
and use English (US) keyboard - United States International.
The keyboard layout is not relevant. It is up to the text editor you use
to interpret what the keypresses mean. The editor does not receive a
character but a numerical code. Depending on which editor you use, and
how it is set up, that numerical code will result in different visible
output on screen.

If you write an application in an editor that uses a Windows codepage
and compile it with a "PT850" codepage setting in the application,
xHarbour will believe that your text strings are PT850 strings, and will
display them incorrectly. If you compile your little test app with the
codepage changed to "PTISO", it will display correctly. That is really
all I suggested: To try different things in a test app and observe how
the result changes.

If you do it the other way around and edit the same test app source code
with a DOS based editor and change the string to look right in that
environment, or if your editor has a function to flip the codepage
(called something like "Convert ANSI to OEM", then your PT850 setting in
the application will make xHarbour display the string correctly.

There are a lot of things you have to learn before your strings with
characters above chr(127) will work correctly. So start searching the
web for "ANSI codepage", "OEM codepage" and similar things and compare
the locations (the numerical values) in the different character sets for
the characters you are interested in, and hopefully you will see the light.

In the end you have to properly align all the following in order to use
characters above chr(127):
The codepage used in the DBF files
The codepage used in the user interface
The codepage used in the text editor
And possibly also the codepage used in the OS (if there are "national"
characters in the file names)

Understanding what different codepages are for and what the
characteristics of each codepage are is the key to success.

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-18 18:14:04 UTC
Permalink
Post by Klas Engwall
Post by Enrico Maria Giordano
The following sample
FUNCTION MAIN()
HB_SETCODEPAGE( "PT850" )
? SET( _SET_CODEPAGE )
? "Coração"
INKEY( 0 )
RETURN NIL
prints
EN
CoraþÒo
What am I missing?
I've already tried with other languages and REQUEST. Same result.
I have not suggested anything for your real application. As Daniele
said, neither you nor Enrico really got the point I was trying to make.
No, *you* missed mine that was: why I get "EN" if I set "PT" language?
Post by Klas Engwall
If you compile your little test app with the codepage changed to "PTISO", it will display correctly.
No, it will not, I tried.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-18 19:38:24 UTC
Permalink
Hi Enrico,
Post by Enrico Maria Giordano
Post by Klas Engwall
Post by Enrico Maria Giordano
The following sample
FUNCTION MAIN()
HB_SETCODEPAGE( "PT850" )
? SET( _SET_CODEPAGE )
? "Coração"
INKEY( 0 )
RETURN NIL
prints
EN
CoraþÒo
What am I missing?
I've already tried with other languages and REQUEST. Same result.
I have not suggested anything for your real application. As Daniele
said, neither you nor Enrico really got the point I was trying to make.
No, *you* missed mine that was: why I get "EN" if I set "PT" language?
Was your point that you get "EN"? Sorry if I didn't understand that. I
was focusing on the display of the Portuguese string that we were
talking about. Anyway, I assumed that you forgot to post the line where
you REQUEST the Portuguese codepage. But apparently you did not include
it in the code snippet you compiled either. You have to both REQUEST and
Set() the codepage you want. xHarbour skips the setting of the codepage
without comment if it has not been linked.
Post by Enrico Maria Giordano
Post by Klas Engwall
If you compile your little test app with the codepage changed to
"PTISO", it will display correctly.
No, it will not, I tried.
Again, it will if the codepage is linked. And it is not linked
automatically just by setting it with HB_SetCodePage()

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-18 19:50:51 UTC
Permalink
Post by Klas Engwall
Post by Enrico Maria Giordano
I've already tried with other languages and REQUEST. Same result.
Was your point that you get "EN"? Sorry if I didn't understand that. I
was focusing on the display of the Portuguese string that we were
talking about. Anyway, I assumed that you forgot to post the line where
you REQUEST the Portuguese codepage. But apparently you did not include
it in the code snippet you compiled either. You have to both REQUEST and
Set() the codepage you want. xHarbour skips the setting of the codepage
without comment if it has not been linked.
You're right! I tried again and now it works:

REQUEST HB_CODEPAGE_PTISO


FUNCTION MAIN()

HB_SETCODEPAGE( "PTISO" )

? SET( _SET_CODEPAGE )

? "Coração"

? HB_ANSITOOEM( "Coração" )

INKEY( 0 )

RETURN NIL

I get

PTISO
CoraþÒo
Coração

But still no joy with the ANSI string... :-(

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-18 21:37:18 UTC
Permalink
Hi Enrico,
Post by Enrico Maria Giordano
REQUEST HB_CODEPAGE_PTISO
FUNCTION MAIN()
HB_SETCODEPAGE( "PTISO" )
? SET( _SET_CODEPAGE )
? "Coração"
? HB_ANSITOOEM( "Coração" )
INKEY( 0 )
RETURN NIL
I get
PTISO
CoraþÒo
Coração
But still no joy with the ANSI string... :-(
Hmm, that's weird. I have used it like that in Harbour for years, and it
has always worked. So, considering the common roots of the two projects
I assumed it would work in xHarbour too. I tried it again now in
Harbour, and it worked. Then I tried it in xHarbour, and it didn't work.
I also tried HB_DispCp(), and that didn't work either. Moving from GTWIN
to GTWVT might help, though, if the goal is to *use* PTISO, not just
experiment with it. That means moving from a CMD console to a Windows
GUI based emulated console.

So, at this point remains what I told the OP about the problem at hand:
He has to use a DOS codepage in the text editor to match the DOS screen
output (PT850).

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-19 08:08:13 UTC
Permalink
Post by Klas Engwall
Post by Enrico Maria Giordano
But still no joy with the ANSI string... :-(
Hmm, that's weird. I have used it like that in Harbour for years, and it
has always worked. So, considering the common roots of the two projects
I assumed it would work in xHarbour too. I tried it again now in
Harbour, and it worked. Then I tried it in xHarbour, and it didn't work.
I also tried HB_DispCp(), and that didn't work either.
So, something to fix in xHarbour. Any clues on where to look?

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-19 20:02:23 UTC
Permalink
Hi Enrico,
Post by Enrico Maria Giordano
Post by Klas Engwall
Post by Enrico Maria Giordano
But still no joy with the ANSI string... :-(
Hmm, that's weird. I have used it like that in Harbour for years, and it
has always worked. So, considering the common roots of the two projects
I assumed it would work in xHarbour too. I tried it again now in
Harbour, and it worked. Then I tried it in xHarbour, and it didn't work.
I also tried HB_DispCp(), and that didn't work either.
So, something to fix in xHarbour. Any clues on where to look?
No, sorry, that is buried too deep down in the sourcecode for me.

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-19 20:04:49 UTC
Permalink
Post by Klas Engwall
Post by Enrico Maria Giordano
So, something to fix in xHarbour. Any clues on where to look?
No, sorry, that is buried too deep down in the sourcecode for me.
Ok. :-(

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
c***@gmail.com
2015-10-18 18:05:00 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Dear Mr. Enrico,

It works, supposing that the MS-DOS codepage is set to 850
This has to be done initial in the main() Program (Run chcp 850)
No Request..... is needed.

It only means that I have to use HB_AnsiToOem("<text>") for every string with accents
Its a little bit more typework.

Thanks for your suggestion!!
perloc
Enrico Maria Giordano
2015-10-18 18:15:27 UTC
Permalink
Post by c***@gmail.com
It only means that I have to use HB_AnsiToOem("<text>") for every string with accents
Its a little bit more typework.
Yes, there must be another way...

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-18 19:51:53 UTC
Permalink
Hi Perloc,
Post by c***@gmail.com
It works, supposing that the MS-DOS codepage is set to 850
This has to be done initial in the main() Program (Run chcp 850)
No Request..... is needed.
And not requesting the appropriate codepage will not help you at all
Post by c***@gmail.com
It only means that I have to use HB_AnsiToOem("<text>") for every string with accents
Its a little bit more typework.
It "kind of" works, but it is a *very* awkward solution. I have never
heard that being seriously suggested for sourcecode before in all my
(x)Harbour years. Doing it correctly from the start in the sourcecode is
really the only way to go.

BTW, the correct way to convert strings between different codepages is
to use the HB_Translate() function. HB_AnsiToOem() and HB_OemToAnsi()
are not recommended.

HB_Translate( <cDataString>, <cFromCodePage>, <cToCodePage> )

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-18 19:56:23 UTC
Permalink
Post by Klas Engwall
It "kind of" works, but it is a *very* awkward solution. I have never
heard that being seriously suggested for sourcecode before in all my
(x)Harbour years.
Please note that I'm *not* suggesting that one has to use
HB_ANSITOOEM(). I just experimenting with something that I'm not
confident with.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
Klas Engwall
2015-10-18 22:35:55 UTC
Permalink
Hi Enrico,
Post by Enrico Maria Giordano
Post by Klas Engwall
It "kind of" works, but it is a *very* awkward solution. I have never
heard that being seriously suggested for sourcecode before in all my
(x)Harbour years.
Please note that I'm *not* suggesting that one has to use
HB_ANSITOOEM(). I just experimenting with something that I'm not
confident with.
OK :-)

I absolutely agree with you about experimenting with all kinds of
solutions for the purpose of learning how things work. But it seems the
OP took it as something you recommended ...

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Enrico Maria Giordano
2015-10-19 08:10:13 UTC
Permalink
Post by Klas Engwall
I absolutely agree with you about experimenting with all kinds of
solutions for the purpose of learning how things work. But it seems the
OP took it as something you recommended ...
Ok, sorry for that. I wasn't clear enough.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
c***@gmail.com
2015-10-18 19:47:35 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Hello Klas,

Thank you for your extended comment!
Your statement:
In your test application above, switch from "PT850" to "PTISO" to see the text displayed correctly.
My:
I interpreted this as a suggestion.
I've tried to do it but it didn't work.
You 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.
Still 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.
I've told xHarbour what code page I'm using by HB_Setcodepage("PT850") but this easy solution didn't work.

Mr Enrico has told me to use HB_AnsiToOem("<text>") and this works! But 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.

For me the problem is solved and I can go on with my program.
In the past I Used "@10,1 say "Cora" + chr(135) + chr(198) + "o", but to know all the chr() codes by hart is difficult.
Now I can easely use the keyboard characters with accents to get it proper printed on screen.

Thanks again!
perloc
Klas Engwall
2015-10-18 22:28:56 UTC
Permalink
Hi Perloc,
Post by c***@gmail.com
Thank 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.com
You 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.com
Still 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.com
I'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.com
Mr Enrico has told me to use HB_AnsiToOem("<text>") and this works!
But it is a pretty awkward solution
Post by c***@gmail.com
But 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.com
For 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.com
Now 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 ---
Enrico Maria Giordano
2015-10-19 08:09:43 UTC
Permalink
Post by Klas Engwall
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.
There is not anymore. At least in my W10 64 bit.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG Music page: http://www.emagsoftware.it/emgmusic
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
c***@gmail.com
2015-10-19 06:03:30 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
OK, I will look for more examples of that "Zillion" (never heard from it!) newgroup items.

And no, I don't have any characters with accents in my databases!
It's only for presenting text on screen. Characters with accents give differend results on screen depended on which computer it is run.
Therefore I have excluded characters with accents to enter in data by a user.

I know. if the codepage is set, all windows editors recognize char. with accents.
In principle you don't have to set a code page in Windows, it automatically is set by yout Language and keyboard installation.
You only have it to set in a MS-DOS window.

I will try to set Notepad++ to OEM. It makes live much easier.
The xHarbour editor, I had a lot of problems with it. It has bugs. Therefore I stepped over to Notepad++. It works fine!
Edit.exe (windows) is too primitive.

I know well what is haxadecimal numbers. But it is not easy to work with it.
I'm grown up with bits, bytes, octal and hexadeimal, that started in 1980!!

I have to go through my whole program (>30.000 lines) to get rid of all the CHR(num) items. But I have the time....


Thanks for your message!!
perloc
dlzc
2015-10-19 14:12:43 UTC
Permalink
Dear cvan...:

On Sunday, October 18, 2015 at 11:03:34 PM UTC-7, ***@gmail.com wrote:
...
Post by c***@gmail.com
In principle you don't have to set a code page in
Windows, it automatically is set by your Language
and keyboard installation.
You only have it to set in a MS-DOS window.
DOS sessions, under NTVDM, run COMMAND.COM. xHarbour makes console programs, that run CMD.EXE.

So what Klas is highlighting (as I glean), it the differences between text embedded in your code, placed there by your text editor; and text that is ultimately displayed by choice of code page. It may be displayed correctly by your text editor, but is not stored as what you think.

xHarbour still relies on 8-bit characters, so code pages are critical. Both in the editor session, as in the executable session. And where you could run CHCP in a DOS session, you cannot do that at all reliably. Yes, it changes the code page, but only for the duration of the RUN command, and only for the thread of the RUN command. It does not change it for your executable. You'd need to:
- have the computer configured for the correct code page, or
- make a batch file for your program, and CHCP runs before your executable, or
- manipulate the registry to make the code page for console apps correct, or
http://stackoverflow.com/questions/14109024/how-to-make-unicode-charset-in-cmd-exe-by-default
- configure the code page via the Windoze functions:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682064%28v=vs.85%29.aspx
... which should be at the heart of our "HB_SetCodePage()"

David A. Smith
c***@gmail.com
2015-10-19 17:03:32 UTC
Permalink
Post by c***@gmail.com
Hello programmers,
I need for Portuguese accents code page 850
Run chcp 850
the codepage in MS-DOS is switched.
But when I use
HB_SetCodePage("PT850")
don't show good on screen
I know that I could use
Chr(<num>) to get the proper letter with the accent,
bur not desirable.
What's wrong?
perloc
Hello David,

This is all going for me much too far!
I Had a simple question about a xharbour function.
That is for me solved in a workable way.

TRhanks,
perloc
Klas Engwall
2015-10-19 20:18:53 UTC
Permalink
Hi Perloc,
Post by c***@gmail.com
This is all going for me much too far!
I Had a simple question about a xharbour function.
That is for me solved in a workable way.
No, no, no!!!

You are making a BIG mistake if you think you have solved the problem.
As Enrico said in a later post yesterday, he was not suggesting that you
use HB_OemToAnsi() as a solution. His suggestion, like mine regarding
PTISO, was just a suggestion to try it in your *test* app and try to
learn something from it. And I suggested you try as many things as
possible in various test apps for the purpose of learning.

You *REALLY* have to study the codepage system to use it correctly.
There is *NO* way around that. If you take the route of least
resistance, as you seem to be contemplating, you are going to regret it
deeply one day.

About not allowing characters with accents in the DBF files (as you
mentioned in another post today), that is not a solution either. The
reason that "Characters with accents give differend results on screen
depended on which computer it is run", as you said in that post, is that
you skipped the nation module in Clipper and have only used the default
"EN" codepage there. So you skipped learning already at that time. You
are doing yourself, and your users, a "HUGE" disservice by not learning
how to handle the Portuguese language correctly.

Please take note!

Regards,
Klas

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
c***@gmail.com
2015-10-20 18:32:19 UTC
Permalink
Hello Klas,

You certainly right.
The thing is that I'm developping this program for already 15 years with, sure,
big time spaces in it.
I want first to have a workable version (I have already one, but there are some bugs in it) before I put the dots (accents!!) on the i.
There is always a lot of clean up to do in a big program (for me as an alone programmer, who does it more for his pleasure than it to bring it on the market).
A program as mine is endless, there is always something to improve!!
At the moment I don't want to spend more time on the codepaging.
There are a lot of more urgent things to do.

perloc

Loading...