删除不需要的多字节字符而不损害“外来”字符

问题描述 投票:0回答:1

在不破坏其他外来字符的情况下删除不需要的 unicode 字符的最佳方法是什么?

็็็็็็็็็็็็็็็็็็็็็็็็็็็

php regex replace unicode sanitization
1个回答
0
投票

如果您过滤正确的 Unicode 范围,这应该有效:

$str = 'Your string with Unicode symbols'
preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $str);

https://3v4l.org/EY06F

http://php.net/manual/en/function.preg-replace.php

© www.soinside.com 2019 - 2024. All rights reserved.