相关疑难解决方法(0)

php中的UTF-8问题:var_export()返回\ 0 null字符,而ucfirst(),strtoupper()等表现得很奇怪

我们正在处理一个以前从未发生过的Joyent Solaris服务器中的奇怪错误(不会发生在localhost或其他两个具有相同php配置的Solaris服务器上).实际上,我不确定我们是否必须查看php或solaris,以及它是否是软件或硬件问题......

我只是想发布这个,以防有人指出我们正确的方向.

所以,问题似乎是在var_export()处理奇怪的角色时.在CLI中执行此操作,我们在localhost机器和两个服务器中获得预期结果,但不在第三个服务器中获得.所有这些都配置为使用utf-8.

$ php -r "echo var_export('ñu', true);"
Run Code Online (Sandbox Code Playgroud)

在旧服务器和localhost (预期)中给出:

'ñu'
Run Code Online (Sandbox Code Playgroud)

但是在服务器中我们遇到了问题(PHP版本=> 5.3.6),\0每当遇到"不常见"的字符时它会添加空字符:è,á,ç,......你给它命名.

'' . "\0" . '' . "\0" . 'u'
Run Code Online (Sandbox Code Playgroud)

关于应该在哪里看的任何想法?提前致谢.


更多信息:

  • PHP version 5.3.6.
  • setlocale() 没有解决任何问题.
  • default_charsetUTF-8php.ini.
  • mbstring.internal_encoding被设置为UTF-8php.ini.
  • mbstring.func_overload = 0.
  • 这在CLI(示例)和Web应用程序(php-fpm + nginx)中都会发生.
  • iconv 编码也是 UTF-8
  • 所有文件utf-8编码.

system('locale') 收益:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
Run Code Online (Sandbox Code Playgroud)

到目前为止完成的一些测试(CLI):

正常行为:

$ php …
Run Code Online (Sandbox Code Playgroud)

php localization utf-8 joyent

9
推荐指数
2
解决办法
2588
查看次数

修复PHP中的字符

任何人都知道这是什么以及如何解决它?"OMG"

<p>After 32 years in its former location, this popular restaurant 
   and bar moved to the bottom of the Avalon Bay Luxury residential building 
   that's just a walk from Angel Stadium. Modern and welcoming, the expansive 
   space is where fans, locals and families gather for upscale twists on classic
   American dishes. Burgers here have a decidedly fun flair like “The OMG� 
   that is a burger surely meant for sharing (with many)--it's so huge that it's 
   served on a 14-inch bun. …
Run Code Online (Sandbox Code Playgroud)

html php encoding utf-8 character-encoding

3
推荐指数
1
解决办法
3807
查看次数

标签 统计

php ×2

utf-8 ×2

character-encoding ×1

encoding ×1

html ×1

joyent ×1

localization ×1