开发者

php regular expression for unicode

开发者 https://www.devze.com 2023-01-18 14:53 出处:网络
I have some text where unicode is written as text l开发者_JAVA百科ike this There areu25ba 2 boys.

I have some text where unicode is written as text l开发者_JAVA百科ike this

There areu25ba 2 boys.

it should be like this

There are&#x25ba 2 boys.

Replace 'u' with '&#x' if there is unicode character.

Thanks in advance


A naive way would be:

preg_replace('/u([0-9a-fA-F]{4})/','&#x$1;',$string);

But I doubt 'udaff' would appreciate it.

0

精彩评论

暂无评论...
验证码 换一张
取 消