string filter: detect non-ASCII signs

前端 未结 3 973
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 01:04

I am creating an application which will send the input string to mobile device. Some devices have problems with encoding special characters so I would like to create a filte

3条回答
  •  庸人自扰
    2021-01-14 01:46

    This is a regex option (using System.Text.RegularExpressions)

        string s = "søme string";
        bool result = Regex.IsMatch(s, @".*[^\u0000-\u007F].*"); // result == true
    

提交回复
热议问题