July 23, 2024, 09:47:57 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


trouble with special characters

Started by philippe.tx, December 07, 2010, 05:50:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

philippe.tx

December 07, 2010, 05:50:06 AM Last Edit: December 07, 2010, 05:52:00 AM by philippe.tx
hi all,
can somebody explain me what is happening here???
(french keyboard, french winxp sp3, french accents)



def i : int
i=asc("a")
print "a"," ", i, " ",chr$(i)
i=asc("e")
print "e"," ", i, " ",chr$(i)
i=asc("u")
print "u"," ", i, " ",chr$(i)
print "-----------"
i=asc("à")
print "à"," ", i, " ",chr$(i)
i=asc("é")
print "é"," ", i, " ",chr$(i)
i=asc("ù")
print "ù"," ", i, " ",chr$(i)
do:until inkey$<>""
closeconsole
end


DennisL

hi philippe.tx, i beleive this has something to do with the character set (i.e. font table) used.  The default console font is SYSTEM, but the default font for the CB editor is something else (I think it's Courier New).  the ASCII set is only the same for characters up to 255, anything above this is different depending on the character set used (and is in fact not part of the ASCII standard anymore).

Egil

I had excatly the same problem with a norwegian language setup. It happened only when trying to print norwegian text in console programs.

Here is a solution I found on the HotBasic forum, and converted to CB. It should work with your system as well.

Regards

Egil

' ConvToOEM.bas
'

DECLARE "user32.dll",CharToOem Alias CharToOemA(lpszSrc:STRING,lpszDst:STRING),INT
Declare ConvToOEM(txt:string)

' --- Test program ---------------------------
openconsole
def tmp1,tmp2:string
tmp1 = "Norwegian characters: æøå ÆØÅ"

print tmp1
print

tmp2 = ConvToOEM(tmp1)
print tmp2

do:until inkey$ <>""
closeconsole
end
'---------------------------------------------


SUB ConvToOEM(txt:string)
def org,ret:string
org = txt
ret = STRING$(len(org), chr$(0))
CharToOem(org,ret)
RETURN ret


Support Amateur Radio  -  Have a ham  for dinner!