2021年6月28日 星期一

判斷char 是否為UTF16

bool isUTF16(char value)
            {
                return Convert.ToInt32(value) >= Convert.ToInt32("d800", 16) && Convert.ToInt32(value) <= Convert.ToInt32("dfff", 16);
            }

※中文字串透過 ToArray() 拆解成 char 陣列時,特殊字會用UTF16處理,一個中文字會變成兩個char(顯示為\uxxxx),並使用d800~dfff的code point

沒有留言:

自訂權限驗證機制

// 使用 filter [Route("api/[controller]")] [ApiController] [Authorize] [TypeFilter(typeof(CustomAsyncAuthorizationFilter))] public c...