Article Preview
Buy Now
| Print: | |
| PDF: |
Ask The Experts
Article
Issue: 2.2 (October/November 2003)
Author: Seth Willits with Thomas Reed
Article Description: No description available.
Article Length (in bytes): 7,441
Starting Page Number: 34
RBD Number: 2215
Resource File(s): None
Related Web Link(s):
http://www.domainsoftworx.com/downloads/DownloadSS.html
http://support.realsoftware.com/listmanager/
http://www.rbgarage.com/
http://www.resexcellence.com/
http://www.applelinks.com/rbu/
http://www.freaksw.com/rbgames/
http://www.monkeybreadsoftware.de/realbasic/plugins.html
Known Limitations: None
Excerpt of article text...
Q: In my MySQL database I insert data into a column encoded as UTF-8, yet when I retrieve the data it comes back as ASCII. Why does it do this?
For simplicity's sake (and probably other reasons), MySQL doesn't respect string encoding. It doesn't matter if the text is put into a column as a UTF-8 or UTF-16 string; MySQL just knows it has a chunk of bytes to treat as a string and passes them along to REALbasic, which in turn just gives it a standard ASCII encoding since version 5 doesn't have the mind-reading feature we've been so desperately waiting for.
If you want to retrieve your data in a specific encoding, you'll have to retrieve the string and then define its encoding to that of your desire using the DefineEncoding method.
Function GetUTF8StringFromRecordColumn(rs as RecordSet, columnName as string) As string
dim UTF8String as String
UTF8String = rs.Field(columnName).StringValue
UTF8String = DefineEncoding(UTF8String, GetTextEncoding(-at-h0100, 0, 0))
return UTF8String
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|











