Unicode character issue while reading from csv file - ios

In my program, i read the content from csv file then display in UILabel.
What is my problem is Unicode character not working while read it from file.
Suppose i do the code like this.
NSString *cubedSymbol = #"10\u00B3";
[label setText:cubedSymbol ];
Output 10³
But same text #"10\u00B3" i read from the file and set it to label.
output 10\u00B3

Related

How to replace these extended ascii codes?

I am opening up .txt files but when they are loaded on Xojo weird characters like these (’ , â€ک) show up.
I've tried DefineEncoding and ConvertEncoding but it still doesn't seem to work.
output.text = output.text.DefineEncoding(Encodings.WindowsANSI)
output.text = output.text.ConvertEncoding(Encodings.UTF8)
You may have to define the encoding already at time of loading, not afterwards, or you'll get UTF8 chara from loading that you will then mess up with your posted code. So, pass the encoding to the Read function or load the data as a binary file, not as a text file.

Change text encoding to No Explicit in localizable file

Currently my text encoding of the Localizable.strings file is set to UTF-8. All my other localizable files are set to no explicit.
I want to change UTF-8 to No explicit, how is it possible ?
If you want to know, it's cause with xCode 10 this error appears
could not decode input file using specified encoding: Unicode (UTF-8), and the file contents appear to be encoded in Unicode (UTF-16)
You could try manually editing the project.pbxproj file to remove the fileEncoding = x for your Localizable.strings file?
To reset the Text-Encoding type. Select your language.string file:
Then select Text Encoding from right hand panel:
Update:
If you accidentally selected the Text-Encoding, then you have to reset it from project.pbxproj. To do this follow below steps:
Open package content of your Project.xcodeproj
Open project.pbxproj and search for your file-name and remove the fileEncoding = <encoding>; (for example: fileEncoding = 4;), and save the file.

Create RTF file with Objective-C

I want to create an RTF file by creating my own source code of the RTF file and inserting in variables from my model.
I am creating the source coude using for example :
NSMutableString *body = [NSMutableString stringWithString:"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang3084\deflangfe3084{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fswiss\fprq2\fcharset0 Calibri;}{\f2\froman\fprq2\fcharset2 Symbol;}}{\colortbl ;\red255\green255\blue255;\red0\green0\blue255;}{\*\generator Riched20 10.0.10240}\viewkind4\uc1\trowd\trgaph70\trleft-108\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx2818\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs"];
I want this string to be saved as an RTF file and then the RTF reader will conver this code to a readable RTF File. The problem is that Xcode gives me numerous errors (unknown escape sequence) due to the characters such as * \d \c \g . Moreover it says "Incomplete universal character name".
How can I have my NSString be treated like source code and ignore all those errors so that it can be parsed in an RTF file.
You need to escape your escape characters "\". When you write it to the console or file your string will output correctly.
NSMutableString *body = [NSMutableString stringWithString:#"{\\rtf1\\ansi\\ansicpg1252\\deff0\\nouicompat\\deflang3084\\deflangfe3084{\\fonttbl{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}{\\f1\\fswiss\\fprq2\\fcharset0 Calibri;}{\\f2\\froman\\fprq2\\fcharset2 Symbol;}}{\\colortbl ;\\red255\\green255\\blue255;\\red0\\green0\\blue255;}{\\*\\generator Riched20 10.0.10240}\\viewkind4\\uc1\\trowd\\trgaph70\\trleft-108\\trbrdrl\\brdrs\\brdrw10 \\trbrdrt\\brdrs\\brdrw10 \\trbrdrr\\brdrs\\brdrw10 \\trbrdrb\\brdrs\\brdrw10 \\trpaddl70\\trpaddr70\\trpaddfl3\\trpaddfr3\\clbrdrl\\brdrw10\\brdrs\\clbrdrt\\brdrw10\\brdrs\\clbrdrr\\brdrw10\\brdrs\\clbrdrb\\brdrw10\\brdrs \\cellx2818\\clbrdrl\\brdrw10\\brdrs\\clbrdrt\\brdrw10\\brdrs\\clbrdrr\\brdrw10\\brdrs\\clbrdrb\\brdrw10\\brdrs"];

Read ZIP with umlaut in filename

A proper ZIP is encoded with code page 437. However this code page is not supported by iOS. Thus I can't extract ZIP files that contain files and folders with special characters like ä, ö or ü.
Objective-Zip and zipzap convert the filename to nil, which makes the file unreadable. ZipKit at least converts the umlauts to a question mark. The file can be accessed, but it still looks weird. Is there a way to access the original, CP473 encoded filenames in iOS?
With zipzap you can specify a non-UTF8 encoding for filename interpretation.
In the 8.0 API:
ZZArchive* archive = [[ZZArchive alloc]
initWithURL:URL
options:#{ ZZOpenOptionsEncodingKey:
CFStringConvertEncodingToNSStringEncoding(
kCFStringEncodingDOSLatinUS) }
error:nil];
In the older API:
ZZArchive* archive = [[ZZArchive alloc]
initWithContentsOfURL:URL
encoding:CFStringConvertEncodingToNSStringEncoding(
kCFStringEncodingDOSLatinUS)];
Well, it's just a code page. Each byte is strictly defined as 1 character, so it shouldn't be hard to write up a simple function to convert it to Unicode byte by byte. All of the code points are listed on the wikipedia page you linked (e.g. 0x81 == \u00FC).

parse XML file that contains unicode characters in iphone

I am trying to parse one XML file that contains some unicode characters.I tried to parse the file using NSXMLParser but i am unable to parse XML.Parser stops when it encounters any unicode characters.
Is there any other good solution to parse XML file with unicode letters?
Please suggest.
Have you tried TBXML for iPhone http://www.tbxml.co.uk/

Resources