Converting encoded string to UTF-8 chars in Mono (569460)
- From: Alexander Skwar <alexanders mailinglists+nospam gmail com>
- To: F-spot-list gnome org
- Subject: Converting encoded string to UTF-8 chars in Mono (569460)
- Date: Sat, 21 Feb 2009 10:41:44 +0100
Hi.
I'm working again on this bug of mine:
[Bug 569460] Unescape special charcters in filenames when doing
(Flickr, Picasa Web, Zip, ...) export
Problem is, that f-spot stores file names encoded in the database, ie.
something like this:
%5B2008-11-12--10.40.37%5D%20(IMG_0017)%20C%C3%A9dric%2C%20Photoshooting%2C%20Petra%2C%20Fotograf.jpg
That's for a file named:
[2008-11-12--10.40.37] (IMG_0017) Cédric, Photoshooting, Petra, Fotograf.jpg
Now, the internal storage is of course no problem at all and shouldn't
matter for a user. But if such a picture is exported to Flickr, PicasaWeb
orZIP file, the encoded filename is "sent" to the "exportee" and they
then show the encoded filename and not the decoded filename, like
it should be.
As you can see on the bug report at
http://bugzilla.gnome.org/show_bug.cgi?id=569460#c3, I wrote
a small patch, which at least transforms things like
%5B2008-11-12--10.40.37%5D%20 to something readable,
ie. "[2008-11-12--10.40.37] ". But UTF-8 encoded filenames like
C%C3%A9dric are not properly decoded to Cédric; instead,
C├Г┬йdric (Zip) or CÃ(c)dric (Flickr) is visible.
I guess I somehow need to tell Mono that a string is UTF-8.
How would I do that?
In the patch, there's this function that needs to be fixed:
// NOTE: Copied from dbus-sharp/Address.cs: Unescape, which isn't public
// This is the reverse function of EscapeString
public static string UnescapeString (string str)
{
if (str == null)
return String.Empty;
StringBuilder sb = new StringBuilder ();
int len = str.Length;
int i = 0;
while (i != len) {
if (Uri.IsHexEncoding (str, i))
sb.Append (Uri.HexUnescape (str, ref i));
else
sb.Append (str[i++]);
}
return sb.ToString ();
}
Thanks a lot,
Alexander
--
[ Soc. => http://twitter.com/alexs77 | http://www.plurk.com/alexs77 ]
[ Mehr => http://zyb.com/alexws77 ]
[ Chat => Jabber: alexws77 jabber80 com | Google Talk: a skwar gmail com ]
[ Mehr => MSN: alexws77 live de | Yahoo!: askwar | ICQ: 350677419 ]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]