unicode question

Just starting out? Need help? Post your questions and find answers here.
User avatar
loadstone
User
User
Posts: 97
Joined: Wed Jan 16, 2008 11:28 am
Location: china

unicode question

Post by loadstone »

:oops:

Code: Select all

Debug Asc("你")
When I change the sourcefile encoding to utf8 and checked the
"create unicode executable",then <ASC"你"> code can not get the value.

ps: if ansi mode,that can get the value.
"你" is a chinese word.
in VB chinese edition can do this Asc("你")=-15133,meybe VB inside immediately use the uncode?
thank :)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Asc() returns the Ascii value, Unicode characters do not necessarily have an Ascii value, so I fear you cannot rely on Asc() here...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

It works for me....

Code: Select all

number=Asc("你") 
Debug number

If OpenWindow(0,0,0,300, 400,"") And CreateGadgetList(WindowID(0))
    StringGadget(0, 20,20, 200, 30, Chr(number)+ " 你 " + Chr(20320))
    SetGadgetFont(0, LoadFont(0, "Arial Unicode MS", 12))
EndIf    
Repeat:Until WaitWindowEvent()=#WM_CLOSE    


I get 20320 and it looks okay.

Unicode on and Utf-8 enabled.
PureBasic for Windows
User avatar
loadstone
User
User
Posts: 97
Joined: Wed Jan 16, 2008 11:28 am
Location: china

Post by loadstone »

oh,I understand :)
it work good!!!!
:lol:
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Isn't there some function to return the unicode value? If not we may need a UNI(ñ) feature! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Well, I don`t have problems with e.g. Asc("‱") + Unicode.

I`ve tried several Unicodes without any problems.

Try it...

For displaying, the right font has to be installed:
http://en.wikipedia.org/wiki/Unicode_typefaces
PureBasic for Windows
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Rook Zimbabwe wrote:Isn't there some function to return the unicode value? If not we may need a UNI(ñ) feature! :D
Asc() is here for that, where is the problem ?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Fred, does it support all unicode formats / codes? If so a little note in the docs would make sense :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sure it does, it returns a character, it's not ascii only. I will update the doc.
Post Reply