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"];
Related
We have a link module that looks something like this:
const string lMod = "/project/_admin/somethingÜ" // Umlaut
We later use the linkMod like this to loop through the outlinks:
for a in obj->lMod do {}
But this only works when executing directly from DOORS and not from a batch script since it for some reason doesn't recognize the Umlaut causing the inside of the loop to never to be run; exchanging lMod with "*" works and also shows the objects linked to by the lMod.
We are already using UTF-8 encoding for the file:
pragma encoding, "UTF-8"
Any solutions are welcome.
Encode the file as UTF-8 in Notepad++ by going to Encoding > Convert to UTF-8. (Make sure it's not already set to UTF-8 before you do it).
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
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).
I have to parse NSData with XML string, does somebody know simple category to do it? I have such for JSON, but I forced to use XML. I tried to use XMLReader, it's interface looks clean, but I found some issues:
Mysterious new line characters and spaces everywhere:
"comment_count" = {text = "\n \n 21";};
My cyrillic symbols looks so:
"description_text" = {text = "\n \U041f\U0438\U043a\U0430\U0431\U0443\U0448};
Example:
<?xml version="1.0" encoding="UTF-8" ?>
<news>
<xml_count>43</xml_count>
<hot_count>449</hot_count>
<item type="text">
<id>1469845</id>
<rating>147</rating>
<pluses>171</pluses>
<minuses>24</minuses>
<title>
<![CDATA[Обновление огромного архива Пикабу!]]>
</title>
<comment_count>26</comment_count>
<comment_link>http://pikabu.ru/story/obnovlenie_ogromnogo_arkhiva_pikabu_1469845</comment_link>
<author>icq677555</author>
<description_text>
<![CDATA[Пикабушники, я обновил свой огромный архив текстовых постов из горячего!]]>
</description_text>
</item>
</news>
I just realized whats' going on. Your data samples are obviously NSDictionary instances printed in the debugger. So the issues you found are:
As XML was originally designed as an annotated text format, the whitespace (spaces, newlines) handling doesn't perfectly fit for data only usage. You can either trim all resulting strings ([stringVar stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]), adapt XMLReader to do it or use the XML parser at http://ios.biomsoft.com/2011/09/11/simple-xml-to-nsdictionary-converter/ (which does it by default).
The funny output you get for Cyrillic characters is the proper escaping for non-ASCII characters in the debugger output (which uses the old-style property list format). It's an artifact of the debugger output. Your variables contain the proper characters.
BTW: While JSON contains implicit type information (strings are always quoted, numbers are never quoted etc.), XML without a schema file does not. So all the parsed simple values will be strings even if they originally were numbers.
Update:
The XML parser you're using still contains the old whitespace handling code described in Pesky new lines and whitespace in XML reader class (though the comment tells otherwise). Apply the fix mentioned at the bottom of the answer, namely change the line:
[dictInProgress setObject:textInProgress forKey:kXMLReaderTextNodeKey];
to:
[dictInProgress setObject:[textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] forKey:kXMLReaderTextNodeKey];
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/