即使尽可能设置UTF-8,也无法显示德语变音符号 [英] Can't display german umlauts even if UTF-8 is set wherever possible

查看:1004
本文介绍了即使尽可能设置UTF-8,也无法显示德语变音符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我解释情况更近。


  1. 我在使用PHP 4的一些旧公司服务器上工作。安装了Windows 2000NT和可以使用Microsoft Access 2000打开的数据库。

  2. 没有任何选项来设置字符编码(与phpMyAdmin不同),但我可以正确读取MS Access中的字符。

  3. 从我的.php文件中的数据库中提取数据,并将其显示在我的网站上,但是字符如:ü,ä,ß显示错误,如下所示:

  4. 所有php / html文件都由一些旧版本的Notepad ++保存为UTF-8编码,并包含:

    <!DOCTYPE html>
    < html lang =de>
    < head>
    < meta charset =utf-8>

  1. Im working on some old company server with PHP 4. There is Windows 2000NT installed and a databaze that I can open with Microsoft Access 2000.
  2. There is no any option to set character encoding (unlike in phpMyAdmin), but I can read that characters in MS Access properly.
  3. Im extracting data from that database in my .php files and displaying it on my website, but characters like: ü, ä, ß are displayed wrong, like this: �
  4. All php/html files are saved by some old version of Notepad++ as UTF-8 encoding and containing: <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8">

我读了一些关于字符编码,字符编码历史和全能UTF- 8,这将解决所有的问题,这是不是真的。什么可能是错误?

I read some theory about character encoding, history of character encoding and almighty UTF-8 that will solve all your problems, which is simply not true. What could be wrong?

推荐答案

首先,确定您的破损字符具有什么字节值。不知道你不能识别要使用的编码。

First, identify what byte values your broken characters have exactly. Without knowing you cannot identify the encoding like to be used.

echo urlencode($string_with_umlauts);

这将打印所有非ASCII字符作为百分比编码的十六进制值。请注意,这个函数是为了其他目的,但它也会在这种情况下帮助。

This will print all non-ascii characters as percent-encoded hex values. Note that this function is meant for some other purpose, but it'll help in this case also.

然后查找维基百科等编码表中的字节,

Then lookup the bytes in encoding tables like Wikipedia and be sure what you have there.

最后一步:添加一个转换层到您的数据库访问逻辑,该逻辑从您看到的编码转换为带iconv功能的UTF-8。

The last step: Add a transformation layer to your database access logic that converts from the encoding you saw to UTF-8 with iconv functions.

这篇关于即使尽可能设置UTF-8,也无法显示德语变音符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆