【问题标题】:Base64 encoded message issue with webservice for mobile app移动应用程序 Web 服务的 Base64 编码消息问题
【发布时间】:2014-10-27 14:27:31
【问题描述】:

我们正在从网站发布一些消息并将其显示在移动应用程序上。 我们将消息以 base64 编码格式存储在 mysql 数据库中。 对于移动应用程序,我们提供 base64 编码字符串,移动开发人员正在从那里进行解码并显示正常文本。 现在的问题是当我们使用'enter,单引号,双引号'时,这些字符会显示为'\n,\'和\"'这样的。 p>

是否有任何解决方案可以在 android 和 iphone 应用程序中正确显示。 或者我们可以从 php 服务器端执行此操作。

【问题讨论】:

    标签: php android ios mysql mobile-application


    【解决方案1】:

    在使用base64EncodedStringWithOptions方法将base64转换为普通字符串时,您需要在iOS中使用NSDataBase64EncodingEndLineWithLineFeed而不是NSDataBase64Encoding64CharacterLineLength参数

    NSString *strNormalText = [yourBase64Data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
    

    如果需要,请尝试以下参数:

    NSDataBase64Encoding76CharacterLineLength
    NSDataBase64EncodingEndLineWithCarriageReturn
    

    注意:在 Android 中可能有相同的选项

    【讨论】:

    • 它对我不起作用。你能建议点别的吗?我正在使用 utf8
    猜你喜欢
    • 2013-07-16
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    相关资源
    最近更新 更多