>The solution is to satisfy its assumption: convert the
>file name string from UTF-8 to the system encoding.
Note that these UTF8 file names can cause all kinds of problems in RB 4.5
(not sure about the latest fc version of 4.5.1, I have just downloaded it
but haven't yet tried it). Saving the file name, or any other UTF8 text,
to a file will cause it to not be recognized as UTF8 text any longer,
making any special characters appear as two or more different special
characters. The same is true for the ReplaceAll or the RegEx replace
function -- the returned result is no longer UTF8 encoded.
You'll need to know how to convert to and from UTF8. If you get the
TextUtilities module, which is on the 4.5 CD if you search for
"TextUtilities", it will help. (I can e-mail it to you if you can't find
it.) It gives you a couple useful methods.
The first is AssertEncoding. When you read previously-UTF8 text from a
file or get it back from ReplaceAll or RegEx, it is still essentially
UTF8 (meaning all the right characters are there), it's just not being
recognized as such. If you do this with the string:
s = AssertEncoding(s, UTF8Encoding)
it will convert it back to a normal UTF8 string.
The problem you've run into is a little different. You've got a valid
UTF8 string that you want to convert to a "normal" string. You can do
this with the ConvertFromUTF8 method from the TextUtilities module to
convert the string to the system encoding. Here's an example:
s = ConvertFromUTF8(s, SystemEncoding)
Here's an important note -- although the file name you GET from a
FolderItem's Name property is UTF8, don't try to SET that property using
a UTF8 string! And don't try to use the FolderItem's Child method with a
UTF8 string. It won't work. You'll need to convert the string to the
system encoding first. Also, if you make a FolderItem to an existing
file, and that file has special characters in it's name, it appears that
the FolderItem will fail. (It will point to a probably non-existant file
with an incorrect name in the same folder as the actual file.) I haven't
found a workaround for this one yet.
-Thomas
Personal web page: http://home.earthlink.net/~thomasareed/
My shareware: http://home.earthlink.net/~thomasareed/shareware/
REALbasic page: http://home.earthlink.net/~thomasareed/realbasic/
Pixel Pen web pub. guide: http://home.earthlink.net/~thomasareed/pixelpen/
Save the whales -- collect the whole set.
|