iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
xpol
V2EX  ›  iDev

怎么把编码为 GB18030 的 UnsafePointer<Int8> 转换成 Swift 3 的字符串?

  •  
  •   xpol · Oct 15, 2016 · 4908 views
    This topic created in 3525 days ago, the information mentioned may be changed or developed.
    我通过 C 库获得的字符串,结果类型在 Swift 3 里面是 UnsafePointer<Int8>,编码是 GB18030 或者是 WIndows 的 CP936 。怎么把这个字符串转换成 Swift 3 的字符串啊? String.Encoding 下面找不到对应 GB18030 或者 CP936 的值。
    3 replies    2016-10-16 09:34:29 +08:00
    Andy00
        1
    Andy00  
       Oct 16, 2016
    Core Foundation 里有一个叫 CFStringEncodings 枚举,里面有 GB18030 的编码,你可以试试
    具体详情见 http://stackoverflow.com/questions/29121906/how-to-change-gb-2312-encoding-to-utf-8
    run2
        2
    run2  
       Oct 16, 2016
    CP936 就是 GBK 么?
    ls 贴的那个就可以了, GB18030 兼容 GBK
    xpol
        3
    xpol  
    OP
       Oct 16, 2016
    就是:

    private static let GB_18030_2000 = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue)))

    好长。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1340 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 17:14 · PVG 01:14 · LAX 10:14 · JFK 13:14
    ♥ Do have faith in what you're doing.