【问题标题】:How to decode a base64 string and select input charset using php?如何使用 php 解码 base64 字符串并选择输入字符集?
【发布时间】:2017-02-18 17:58:59
【问题描述】:

如何使用 php 解码 base64 字符串并选择输入字符集?

例如它在这里可以正常工作:https://www.base64decode.org

我想使用 php 解码 base64 字符串,并且我想选择 Windows-1252 字符集。

我使用这个代码:

base64_decode($encode);

但它不显示 Windows-1252 字符集!

谁能帮帮我?

【问题讨论】:

  • 我们来看一些实际的例子。

标签: php character-encoding base64 decode windows-1252


【解决方案1】:

您可以使用base64_decode($encode); 进行解码,但随后您可以使用iconv() 将字符集转换为您想要的字符集。您必须首先知道$encode 数据使用的是什么字符集。

例如,如果 $encode 数据使用 utf-8,则使用以下内容:

$decoded = base64_decode($encode);
$text = iconv("UTF-8", "ISO-8859-1", $decoded);

更多信息:http://php.net/manual/en/function.iconv.php

【讨论】:

    猜你喜欢
    • 2012-11-02
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多