使用PHP v7.1.5,如果字符串包含扩展的ASCII代码A0
("非中断空格"根据{{3),为什么PHP函数mb_eregi_replace
返回NULL }})?
$ php -a
Interactive shell
php > $t = mb_eregi_replace('d', '', "do\xA0not");
php > echo $t;
php > if( $t === null ) { echo "is null"; } else { echo "replace worked"; }
is null
php > $t = mb_eregi_replace('d', '', "do not");
php > echo $t;
o not
php > if( $t === null ) { echo "is null"; } else { echo "replace worked"; }
replace worked
答案 0 :(得分:0)
阅读this article(特别是“如何将扩展ASCII转换为UTF-8”部分)显示在将字符串传递给mb_eregi_replace
之前将其传递给$ php -a
Interactive shell
php > $t = mb_eregi_replace('d', '', utf8_encode("do\xA0not"));
php > echo $t;
o not
解决了问题
DataColumn[] columns = tbl.Columns.Cast<DataColumn>().ToArray();
bool anyFieldContainsPepsi = tbl.AsEnumerable()
.Any(row => columns.Any(col => row[col].ToString() == "PEPSI"));