想要一個在TSQL直接可以用來判斷欄位中是否含有造字(本倫是採用司法院造字程式) 的字在里頭的功能
爬了一下文,沒找到有人寫好的, 不過倒是有很多教你如何判別是否為中文的方法
參考了一下這篇討論, 想自已寫一個CLR看看
先在CONSOLE試看看,
public static void test2(string content)
{
Encoding Encoding950 = Encoding.GetEncoding(950);
byte[] bytes = Encoding950.GetBytes(content);
byte[] bytes1 = new byte[1];
byte[] bytes2 = new byte[2];
byte hibyte;
byte lowbyte;
for (int i = 0; i < bytes.Length; i++)
{
hibyte = bytes[i];
if (hibyte < 128) //英文或unicode
{
bytes1[0] = hibyte;
Console.WriteLine("ascii" + hibyte.ToString());
Console.WriteLine(Encoding950.GetString(bytes1));
}
else
{
i++;
lowbyte = bytes[i];
bytes2[0] = hibyte;
bytes2[1] = lowbyte;
//Console.WriteLine("high: " + hibyte.ToString());
//Console.WriteLine("low : " + lowbyte.ToString());
//Console.WriteLine("high: " + Convert.ToString(hibyte, 16));
//Console.WriteLine("low : " + Convert.ToString(lowbyte, 16));
Console.WriteLine(Encoding950.GetString(bytes2));
string hex = Convert.ToString(hibyte, 16) + Convert.ToString(lowbyte, 16);
Console.WriteLine("hex: " + hex);
Console.WriteLine(hex.CompareTo("A140").ToString()); //-1為範圍外
Console.WriteLine("FEFE".CompareTo(hex).ToString()); //1為範圍外
}
}
Console.ReadLine();
}
不太確定這樣判斷high byte和low byte對不對
但試了幾個造字看來判斷都正確地...
最後延續之前寫的DLL ( sql server clr user defined functions), 再加一個function 部署到DB就大功告成了..
2010年3月16日 星期二
訂閱:
張貼留言 (Atom)
pdf.js 無法顯示部份字
有個檔案在pdf viewer套件中無法顯示內容,但下載檔案後使用工具又可以正常顯示。 本來以為是套件版本太舊的原因,於是去下載pdf viewer套件 https://github.com/mozilla/pdf.js 更新後還是一樣。 覺得應是字型缺漏的問題,於是用PDF-X...
-
上網找了免費的白箱檢測工具,找到了 puma scan 因為支援OWASP TOP 10的檢測,所以這是一個符合客戶需求又能與Visual studio結合的工具(白話說...交差了事矣....) 更重要的是這不用錢....檢測工具都貴森森的,尤其是源碼檢測工具。 ht...
-
建了一個工作排程,定時執行batch檔。 batch中寫了一段xcopy,主要針對有異動較新檔案時才複製。 echo off for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find...
-
.net 執行SQL指令時,出現以下錯誤。 已經開啟一個與這個 Command 相關的 DataReader,必須先將它關閉。 在web.config connectionstring 加入 "MultipleActiveResultSets=True...
沒有留言:
張貼留言