nsstringencoding

NSData encoding

梦想与她 提交于 2019-12-12 06:10:02
问题 Currently, I'm trying to parse an NSData in my iOS app. Problem is, I can't seem to find a proper hebrew encoding for parsing. I must decode the data using the Windows-1255 encoding (hebrew encoding type for windows) or ISO 8859-8 encoding, or I'll get plain gibberish. The closest I've got to solving the issue was using CFStringConvertEncodingToNSStringEncoding(CFStringEncodings.ISOLatinHebrew) yet it throws 'CFStringEncodings' is not convertible to 'CFStringEncoding' (notice Encoding s vs

Cannot pass special characters to an NSTask

扶醉桌前 提交于 2019-12-11 23:55:26
问题 In Cocoa, I would like to pass a string containing special characters to an NSTask as arguments, however the task does not get the proper string. NSString *city=@"Zürich"; // This is the string with a special character [arguments addObject:[NSString stringWithFormat:@"-iptc:city=%@",city]]; NSTask *task=[NSTask new]; [task setLaunchPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"exiftool"]]; [arguments addObjectsFromArray:[NSArray arrayWithObjects:@"-L",@"

Converting NSData to NSString without encoding

二次信任 提交于 2019-12-08 10:08:38
问题 I am trying to upload a image onto server's database. For that I have done Converted image to nsdata using UIImageJPEGReprenstation. Converted nsdata to nstring using base64lib. Problem here is that nsstring that I have is NSASCII encoded. So the default open ssl converters are not able to read the file and convert it into correct images on server side. So what i need is The nsstring that I have created from nsdata must not be encoded using nsascii or nsutf8 or something, as the image data is

Dealing with special characters like (ö, Ä, é, ß) in iOS

寵の児 提交于 2019-12-08 00:21:54
问题 I am fetching data from URL, and this data contains special characters, such as in the name Désirée . I want to display this in my TableView cell, but when I display it, it looks like this: Dösiröe . How do I make it display correctly? Fetch data NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL] encoding: NSStringEncodingConversionAllowLossy error:nil]; SBJSON *parser = [[SBJSON alloc] init]; dictShow = [parser objectWithString:jsonString error:nil]; arr=

Dealing with special characters like (ö, Ä, é, ß) in iOS

ε祈祈猫儿з 提交于 2019-12-06 11:52:39
I am fetching data from URL, and this data contains special characters, such as in the name Désirée . I want to display this in my TableView cell, but when I display it, it looks like this: Dösiröe . How do I make it display correctly? Fetch data NSString *jsonString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL] encoding: NSStringEncodingConversionAllowLossy error:nil]; SBJSON *parser = [[SBJSON alloc] init]; dictShow = [parser objectWithString:jsonString error:nil]; arr=[dictShow copy]; Display Data in TableView cell.textLabel.text = [arr objectAtIndex:indexPath.row]; just

iphone - display encoded characters like å,ä,ö in UILabel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 10:32:27
问题 I have a list that uses UILabel for each of its rows. If I try to display special characters such as å,ä,ö, it displays them as &aring &auml &ouml How do I convert them into a UTF8 encoded NSString? 回答1: The characters display correctly in a WebView because the HTML entities are correctly interpreted by it. Maybe this handy NSString category can help you to display the text how you want in a UILabel: https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m Import both

Convert TXT File of Unknown Encoding to String

梦想的初衷 提交于 2019-12-01 20:39:00
How can I convert Plain Text (.txt) files to a string if the encoding type is unknown? I'm working on a feature that would allow users to import txt files into my app. This means the file could have been created in any number of apps, utilizing any of a variety of encodings that would be considered valid for a plain text file. My understanding is this could include (ASCII, UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, or EBCDIC?!) Things had been going well using the following: NSString *txtFileAsString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding

Function to detect the NSStringEncoding from NSURLResponse?

只谈情不闲聊 提交于 2019-12-01 11:31:24
I just wanted to know if there is any existing category or any sort of function that will return me NSStringEncoding constant out of NSURLResponse object . The issue I am facing at the moment is as I have hardcoded the encoding to NSUTF8StringEncoding when I convert the web service response data to String then it actually causes an issue , as my web service sometimes returns the response encoded in UTF8 and sometimes encoded in ASCII ( well I am not too sure about all the encodings though but yes there are sometimes other languages characters in the response like Japanese , Chinese etc ) So My

Is there a way to “auto detect” the encoding of a resource when loading it using stringFromContentsOfURL?

爱⌒轻易说出口 提交于 2019-12-01 10:38:29
Is there a way to "auto detect" the encoding of a resource when loading it using stringFromContentsOfURL? The current (non-depracated) method, + (id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error; , wants a URL encoding. I've noticed that getting it wrong does make a difference for what I want to do. Is there a way to check this somehow and always get it right? (Right now I'm using UTF8.) Dave.B I'd try this function from the docs Returns a string created by reading data from a given URL and returns by reference the encoding used to interpret the

Function to detect the NSStringEncoding from NSURLResponse?

耗尽温柔 提交于 2019-12-01 07:32:39
问题 I just wanted to know if there is any existing category or any sort of function that will return me NSStringEncoding constant out of NSURLResponse object . The issue I am facing at the moment is as I have hardcoded the encoding to NSUTF8StringEncoding when I convert the web service response data to String then it actually causes an issue , as my web service sometimes returns the response encoded in UTF8 and sometimes encoded in ASCII ( well I am not too sure about all the encodings though but