[C++] File URIs with non-ascii characters

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
miket
Posts: 4
Joined: Tue Sep 09, 2008 5:03 pm

[C++] File URIs with non-ascii characters

Post by miket »

I am trying to use the XComponentLoader to open a document in OpenOffice 3.0 (or 2.4, same problem) from a C++ program. The file is name blå.txt (third letter is the å character). In my program the file name is UTF-8 encoded. Before passing the file name to the ComponentLoader I use FileBase::getFileURLFromSystemPath(), to create the URL. Since getFileURLFromSystemPath() takes the "system path" as an OUString, I create an OUString from my UTF-8 file name -- using RTL_TEXTENCODING_UTF8. On Windows XP and Mac platforms this works fine, ie. the file is found and opened. On Linux, however, OpenOffice cannot find the file.
On Linux, the file has a name that is just a sequence of bytes -- in my case "blå.txt" encoded in UTF-8 (ie. eight bytes, excluding the terminating '\0'). And I guess the reason that OpenOffice cannot create a valid URL from my OUString "system path" is that I have nowhere to specify that I use the UTF-8 encoding.
So what is it that I don't get here..? And does anyone know how to solve my problem..?

I have tried to use the ExternalUriReferenceTranslator on the URL that I get from getFileURLFromSystemPath(). This works on Linux but doesn't work on the other platforms -- and I can't see why it should be nescessary...

Kind regards,
Mike
OOo 2.4.X on Ms Windows XP + Mac OSx
Post Reply