日语字符串上的explode() [英] explode() on Japanese string

查看:138
本文介绍了日语字符串上的explode()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在日语文本上使用explode()函数,但是它不起作用。



以下是我所拥有的示例

  $ string ='私はイタリア人です'; 
$ string = explode(,$ string);
print_r($ string);

可以打印

  Array([0] =>私はイタリア人です)

  Array([0] =>私[1] =>は[2] =>イタリア[3 ] =>人[4] =>です)

似乎 explode()无法识别该文本内的空格。



原因是什么?我该如何工作?

解决方案

原因很简单,您在此处没有空格。
您有一个象形文字空间字符,其十六进制代码为 e3 80 80。



如果使用该字符作为分隔符,它将起作用。 / p>

I have to use the explode() function on Japanese text but it doesn't work.

Here is an example of what I have

$string = '私 は イタリア 人 です';
$string = explode(" ", $string);
print_r($string);

That prints

Array ( [0] => 私 は イタリア 人 です )

in place of

Array ( [0] => 私 [1] => は [2] => イタリア [3] => 人 [4] => です )

It seems that explode() can't recognize the spaces inside that text.

What's the reason? How could I make it work?

解决方案

That is for the simple reason that you do not have a space character here. You have an "IDEOGRAPHIC SPACE" character with the hex code "e3 80 80".

If you use that as your delimiter, it will work.

这篇关于日语字符串上的explode()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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