如果我只知道该文本,如何知道MySql数据库中文本字段中的哪些字符集

时间:2021-10-05 07:17:03

Problem begin when they change php ver from 5.3 to (5.4., 5.5, 5.6)

当php ver从5.3更改为(5.4。,5.5,5.6)时出现问题

I have in table text like this :

我有这样的表格文字:

$rus3="Ð’Ñ‹ не хватает путевок. ДоплачиваетÑÑ. Ðажмите OK и выберите нужный пакет ...";

I have the need to convert lots of text in readable table under utf8

我需要在utf8下转换可读表中的大量文本

Then I use:

然后我用:

$rust3=iconv("UTF-8","windows-1252//IGNORE",$rus3);

And this is on russian Cyrilic like this:

这是俄罗斯Cyrilic这样的:

rust3: Вы не хватает путевок. Доплачивает��. �ажмите OK и выберите нужный пакет ...

rust3:Вынехватаетпутевок。 Доплачивает。 ажмитеOKивыберитенужныйпакет...

But not all characters are transform , and some characters not well convert with this parameters of function iconv . I also have more 4 language with special characters deppending of language in database fields, whot I must convert that be visible and legible .

但并非所有字符都是变换的,并且某些字符不能很好地转换为函数iconv的这些参数。我还有更多4种语言,特殊字符在数据库字段中依赖语言,我必须将其转换为可见且易读。

How I can know in which character set are text, if have only that text ( simbols ) and how is the best way to convert it in utf8. When I get from sql command in mysql database character set it show that is already in utf8.

我怎么知道哪个字符集是文本,如果只有那个文本(simbols)以及如何在utf8中转换它的最佳方法。当我从mysql数据库字符集中的sql命令获得时,它显示已经在utf8中。

1 个解决方案

#1


you can try

你可以试试

$str = "bla bla bla";
echo mb_detect_encoding($str);

will give you char set

会给你char集

How ever to check charset of mysql db you can use

如何检查你可以使用的mysql数据库的字符集

mysql_client_encoding($conn);

so as per your question can you try

所以根据你的问题,你可以尝试

echo mb_convert_encoding($rus3, "UTF8", "auto"); instead iconv. If that helps check more about mb_convert_encoding

echo mb_convert_encoding($ rus3,“UTF8”,“auto”);而不是iconv。如果这有助于检查有关mb_convert_encoding的更多信息

#1


you can try

你可以试试

$str = "bla bla bla";
echo mb_detect_encoding($str);

will give you char set

会给你char集

How ever to check charset of mysql db you can use

如何检查你可以使用的mysql数据库的字符集

mysql_client_encoding($conn);

so as per your question can you try

所以根据你的问题,你可以尝试

echo mb_convert_encoding($rus3, "UTF8", "auto"); instead iconv. If that helps check more about mb_convert_encoding

echo mb_convert_encoding($ rus3,“UTF8”,“auto”);而不是iconv。如果这有助于检查有关mb_convert_encoding的更多信息