nsstringencoding

Unable to create NSUrl from NSString always getting nil

守給你的承諾、 提交于 2020-01-30 02:45:10
问题 NSMutableString *string = [[NSMutableString alloc]initWithString: @"http%3A%2F%2Fsupport24hour.com%2Fworkplace2%2Fbuttler%2Fimage.php%3Fwidth%3D534%26height%3D256%26image%3Duploads%2Fdeals%2FdealImage%2Fdeal_1383005121_IGA+Logo.JPG"]; [string replaceOccurrencesOfString:@"+" withString:@" " options:NSCaseInsensitiveSearch range:NSMakeRange(0, [string length])]; NSURL * url = [NSURL URLWithString:[string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 回答1: one of my

Unable to create NSUrl from NSString always getting nil

…衆ロ難τιáo~ 提交于 2020-01-30 02:44:59
问题 NSMutableString *string = [[NSMutableString alloc]initWithString: @"http%3A%2F%2Fsupport24hour.com%2Fworkplace2%2Fbuttler%2Fimage.php%3Fwidth%3D534%26height%3D256%26image%3Duploads%2Fdeals%2FdealImage%2Fdeal_1383005121_IGA+Logo.JPG"]; [string replaceOccurrencesOfString:@"+" withString:@" " options:NSCaseInsensitiveSearch range:NSMakeRange(0, [string length])]; NSURL * url = [NSURL URLWithString:[string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 回答1: one of my

Convert TXT File of Unknown Encoding to String

女生的网名这么多〃 提交于 2020-01-11 09:18:47
问题 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

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

随声附和 提交于 2019-12-30 10:47:07
问题 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.) 回答1: I'd try this function from the docs Returns a string

How to find and replace a particular unicode character with a non-unicode character in an NSString?

杀马特。学长 韩版系。学妹 提交于 2019-12-25 10:01:25
问题 I am being provided a string that may have a unicode apostrophe in it (\u2019) and I must replace it with a standard apostrophe (plain old "'"). I usually use stringByReplacingOccurrencesOfString to do this kind of thing but trying this does not work: sMyString = [sMyString stringByReplacingOccurrencesOfString:@"\\u2019" withString:@"'"]; Makes sense that it didn't work I guess since the actual values representing the apostrophe internally in the NSString will be numeric. Anyone know how to

How to display tamil characters into UITextView from .rtf/.doc file

不羁的心 提交于 2019-12-24 13:41:20
问题 This is my .rtf file which i included into resources folder of my Xcode project Code which i used for displaying contents of .rtf file into UITextView NSString *filePath=[[NSBundle mainBundle]pathForResource:@"sample" ofType:@"rtf"]; NSString *contentString=[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; myTextViewObj.text=contentString; Output which i got is If anyone knows how to display tamil characters into UITextView from .rtf / .doc / .plist format

Base64 issue in NSMutableURLRequest POST message?

余生颓废 提交于 2019-12-22 20:01:10
问题 I'm having communcation issues between my app and the server. I'm using RNCryptor to encrypt a message, which I then base64 encode and transfer to the server in the request. This is done in both the DATA header, and within the http body as post data. I think I'm making a mistake in how I'm converting & transferring the base64 encoded message via POST. If I receive the encrypted message via the header, it decrypts perfectly fine, every single time. However, if I take the message via the POST

How to remove the last unicode symbol from NSString

痞子三分冷 提交于 2019-12-18 02:54:25
问题 I have implemented a custom keyboard associated with a text field, so when the user presses the delete button, I remove the last character from the string, and manually update the current text field text. NSRange range = NSMakeRange(currentTextFieldString.length-1, 1); [currentTextFieldString replaceCharactersInRange:range withString:@""]; So far so good. Now, the problem is, that the user has the option to enter some special unicode symbols, these are not 1 byte, they can be 2 bytes too, now

ios convert NSString with special chars to const char

自作多情 提交于 2019-12-13 03:53:37
问题 i m trying to draw a string with CGContextShowTextAtPoint. CGContextShowTextAtPoint only accepts "const char" as a string input. my problem is that some of the strings have special chars like ä,ö,ü etc in them. if i convert this strings to a "const char" NSString *label = @"Küche"; const char *charLabel = [label UTF8String]; i get a strange output, where the ü is replaced with signs and boxes... what to do? 回答1: You can draw only ASCII characters with CGContextShowTextAtPoint . To draw

How to represent NSString with '\336\362\340' value in appropriate encoding as normal text?

爷,独闯天下 提交于 2019-12-13 01:43:11
问题 I got strings like this from audio stream as titles: Þòà - Ïàäàòü I know that this string in russian. And I need to show it correctly in UILabel. I try this: NSData *data = [value dataUsingEncoding:NSNonLossyASCIIStringEncoding]; NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; Now goodValue contains next value: \336\362\340 - \317\340\344\340\362\374 Number of characters as I see the save with original. But how I should convert it into normal string