UTF8转换为latin1_swedish_ci [英] UTF8 to latin1_swedish_ci
问题描述
有很多关于latin1_swedisch_ci到utf8转换的主题.但是反过来呢?我已经解决了很长时间了,到目前为止还没有找到解决方案.由于我不知道还有什么可以访问该数据库,所以我不想更改表的字符编码.
There are a lot of topics about latin1_swedisch_ci to utf8 conversion. But what about the other way around? I'm dealing for quite a long time with this problem and I haven't found a solution so far. Since I don't know what else is accessing this database, I don't want to change the character encoding of the table.
我在表中有一列,其格式为latin1_swedisch_ci.现在,我必须在php中编写查询.该数据库包含德语和法语名称,这意味着我拥有ö,ä,ô等字符.我怎样才能做到这一点?
I have in the table a column which is formatted in latin1_swedisch_ci. Now I have to write queries in php. This database contains German and French names, meaning that I have characters like ö,ä,ô and so on. How can I do that?
例如,如果要查询名称Bürki",则必须编写类似$ name ='BÃrrki'的名称.是否有适当的方法可以将其转换为latin1_swedisch_ci,而无需对那些特殊字符进行字符串替换?
As an example if I want to query the name 'Bürki', then I have to write something like $name='Bürki'. Is there a proper way to convert it to latin1_swedisch_ci without using string replacement for those special characters?
推荐答案
iconv()
会将一个字符串转换为一个字符串互相编码.
iconv()
will convert strings from one encoding to the other.
您感兴趣的编码是utf-8
和iso-8859-1
-后者与latin1
等效.
The encodings that are of interest to you are utf-8
and iso-8859-1
- the latter is equivalent with latin1
.
瑞典语",德语"等本地化仅影响排序等问题,字符编码始终相同.
The "swedish", "german" etc. localizations affect issues like sorting only, the character encoding is always the same.
PS.
然后我必须写类似$ name ='Bürki'的东西.
then I have to write something like $name='Bürki'.
如果将源文件编码为UTF-8,则可以直接编写Bürki
. (然后,您必须将该字符串转换为iso-8859-1
)
If you encode your source file as UTF-8, you can write Bürki
directly. (You would then have to convert that string into iso-8859-1
)
这篇关于UTF8转换为latin1_swedish_ci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!