I have an application that reads the data in UTF-8 format from the server, but it has to be displayed in ISO 8859-1(Latin-1). Are there any Cocoa APIs to achieve this?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Swift - hide pickerView after value selected
- iconv() Vs. utf8_encode()
- How do you detect key up / key down events from a
You can use
NSString
'sgetCString:maxLength:encoding:
method, like this:Once you have this, you can then re-initialize an
NSString
instance from that same encoding using thestringWithCString:encoding:
class method:I prefer using
dataUsingEncoding:allowLossyConversion:
because it doesn't require you to guess how much storage to allocate, and the returned NSData tells you how many bytes were required.use
Example:
That should do it.
Jacobs answer didn't really work for my. What did eventually work for me was to only use