Question about strings

BlitzMax Forums/BlitzMax Programming/Question about strings

Henri(Posted 2011) [#1]
Hello all,
I've used Blitzbasic from the days of Amiga and I think it's fantastic language (in the early days the sheer speed :-)) and now I have come across a problem when using Brucey's ODBC-database module that I hope someone might know about. I'm tryin to retrieve data from our database at work(Oracle) which all and all goes fine, but when receiving string-data with getstring()-function all scandic-characters (like ÄÖÅ)are wrong or they don't show at all. For example string "PYÖRÄ" comes out as "PYR¬". Access seems to get the right result. Any help is welcome.


jsp(Posted 2011) [#2]
Does the getstring() function may return an UTF8 string?
Just try
NewString:$ = OldString.FromUTF8String()
to convert and check if that helps.


Henri(Posted 2011) [#3]
I'm not sure about standard response time, but that was quick:) I tried with that, but alas the result is kinda'h same. See example:
If record.value(8)
    local source:string = record.value(8).getstring()
    Local target:String = source.FromUTF8String(source)
    Print target
EndIf


The result of this is " PYR̈ ". I think that the original data is not in UNICODE-format.

Thank you for your reply thou.


Henri(Posted 2011) [#4]
Actually the result seemed like " PYR ". Those additional characters come from copy/paste operation from blitzmax console.


jsp(Posted 2011) [#5]
Encodings
HTML Entity (decimal) ̈
HTML Entity (hex) ̈
How to type in Microsoft Windows Alt +308
UTF-8 (hex) 0xCC 0x88 (cc88)
UTF-8 (binary) 11001100:10001000
UTF-16 (hex) 0x0308 (0308)
UTF-16 (decimal) 776
UTF-32 (hex) 0x00000308 (308)
UTF-32 (decimal) 776
C/C++/Java source code "\u0308"
Python source code u"\u0308"

so yours look like a HTML encoding

Last edited 2011


Henri(Posted 2011) [#6]
Could this be ? Not sure if that was an artifect of copy/paste operation, but any suggestion on getting the data correctly ?


jsp(Posted 2011) [#7]
Who knows;)
Does the user enter the data a copy and paste is quite possible.
But normally the data should be converted before it reaches the database, or not?
You could use a converter to translate it:
http://www.coolutils.com/CommandLine/TotalHTMLConverter
I haven't used it yet myself though.


Henri(Posted 2011) [#8]
Thanks for your reply, I didn't even consider that the data in the field in question could be in any other format than UTF or ANSI (don't know much about text formats). I will try with that approach. Thanks and merry christmas :-)