How to fix encoding issues ? (NSString / XMLParsing) - ios

I parsed an XML file containing UTF8/latin characters (é, â, è, î, etc...).
At first I tried to fix this with a function replacing the wrong chars. But I'm having a problem with à, replaced by ".
And as I don't want to replace all the " of my file, I have to find another way to fix it.
Any idea to fix this ?
Thanks a lot for your advices

To finally answer this question, it worked using TBXML. But only with UTF-8 encoding, not ISO-8859-1.

Related

\u0092 is not printed in UILabel

I have a local json file with some descriptions of an app and I have found a weird behaviour when parsing \u0092 and \u0091 characters.
When json file contains these characters, the corresponding parsed NSString is printed like "?" and in UIlabel it dissapears completely.
Example "L\u2019H\u00e9r." is showed as "LHér." instead of "L'Hér."
If I replace this characters with \u2019, then I can see the caracter ' in UILabel
Does anybody any clue about this?
EDIT: For the moment I will substitute both of them with character \u2019, it is also a ' and there is no problem confusing it with a control character. Thank you all!
This answer is a little speculative, but I hope it gets you on the right tracks.
Your best bet may be to give up and substitute \u0091 and \u0092 for something else as a preprocessing step before string display. These are control characters and are unprintable in most encodings. But:
If rest of the file is proper UTF, your json file probably has problems: encoding is wrong (CP-1250?) while you read the file as UTF, some error has been made when converting the file, or a similar issue. So another solution is of course fixing your file.
If you're not sure about how your file is encoded, it may simply be encoded in CP-1250 - so reading the file using NSWindowsCP1250StringEncoding might fix your problem.
BTW, if you hardcode a string #"\u0091", you'll get a compilation time error Universal character name refers to a control character. Yes, not even a warning, it's that much unprintable in Unicode ;)

Transmitting newline character "\n"

Given the following URL (working, try it!)
https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524&currency=GBP&amount=1401.49&testMode=100&name=Tom%20Gul&address=24%20House%20Road\nSome
Place\nCounty&postcode=TR33%20999&email=email#mail.com&country=GB
If you click on the link and go through to the payment page, the address in the address box is not displaying properly, the newline characters are displaying as text.
I've tried passing through <br />'s but no luck, anyone got any ideas? I need to get the address to display with newlines.
Commas are OK as a separator but i would much prefer being able to have newlines. Thanks for any help! A working example will be the accepted answer.
Try using %0A in the URL, just like you've used %20 instead of the space character.
Try to replace the \n with %0A just like you have spaces replaced with %20.
Use %0A (URL encoding) instead of \n (C encoding).
late to the party, but if anyone comes across this, javascript has a encodeURI method
Replace the \n with %0A.
That's all.

How do I show non-standard characters in the address bar?

I have a bugging problem. For a website I made there are search engine friendly URL's generated. The only problem is there are ß-chars in the url too. Chars like ö, ï, ä, ü etc. are placed correct. But with the ß-char there is a diamond-icon with a questionmark in it.
I thought it had to do with the charset which is used but i've tried both UTF-8 and iso-8859-1. Both without luck.
I need to have the correct character in the url for the readability of deeplinks.
Solved the problem with iconv function.

Multibyte characters in URL are not rendering

I have a bugging problem. For a website I made there are search engine friendly URL's generated. The only problem is there are ß-chars in the url too. Chars like ö, ï, ä, ü etc. are placed correct. But with the ß-char there is a diamond-icon with a questionmark in it. -> �
I thought it had to do with the charset which is used but i've tried both UTF-8 and iso-8859-1. Both without luck.
I need to have the correct character in the url for the readability of deeplinks.
does the character U+00DF in UTF8 work with you?
i tried to use it on Firefox and the URL was translated into ss
in URL encoding, the U+00DF should be translated to %DF
Thanks for your answers, both + 1. I've solved the problem by using the iconv function, which is installed by default.

Why do Umlauts and special characters not show up correctly in my Grails pages?

How do I make sure the correct encoding (UTF-8) is used by Grails?
Easier than I thought - simply make sure your editor is set to UTF-8 encoding.
I've found that sometimes setting the file type to UTF-8 isn't enough. Sometimes you need to tell the AppServer.
response.setContentType("text/html; charset=UTF-8");
request.setCharacterEncoding("UTF-8");
Maybe you shouldn't use UTF-8. Maybe you should try one of the 8859 ISO charsets:http://www.global-translation-services.com/iso8859.html#ISO-8859-1

Resources