php 中俄语的 mb_convert_encoding

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1187652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 01:25:29  来源:igfitidea点击:

mb_convert_encoding for russian in php

phputf-8character-encodingcyrillic

提问by coderex

how to convert Russian character to utf-8 in PHP using mb_convert_encoding or any other method?

如何使用 mb_convert_encoding 或任何其他方法在 PHP 中将俄语字符转换为 utf-8?

采纳答案by fresskoma

Did you try the following? Not sure if it works, though.

您是否尝试过以下操作?不过不确定它是否有效。

mb_convert_encoding($str, 'UTF-8', 'auto');

回答by Timo Huovinen

$file = 'images/да так 1.jpg';//this is in UTF-8, needs to be system encoding (Russian)
$new_filename = mb_convert_encoding($file, "Windows-1251", "utf-8");//turn utf-8 to system encoding Windows-1251 (Russian)

now your russian files should open your russian characters in php are already utf-8 what you need to do is have the name in the same encoding type as your system encoding

现在你的俄文文件应该在 php 中打开你的俄文字符已经是 utf-8 你需要做的就是使用与系统编码相同的编码类型的名称

or if you need the opposite...

或者如果你需要相反的...

$new_filename = mb_convert_encoding($file, "utf-8", "Windows-1251");