想要一個在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)
IIS 網站無法下載中文檔名檔案因為取消高位元字元
網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...
-
一個老舊的aspx web form專案,調了一些功能建置成功,但進行部署時顯示以下錯誤。 在應用程式層級之外使用註冊為 allowDefinition='MachineToApplication' 的區段發生錯誤。錯誤的原因可能是虛擬目錄尚未在 IIS 中設定為...
-
Row.Cells[2].Text == "abc" ? "ok" : "not ok" ; 或加入Microsoft. VisualBasic 參考使用 vb namespace using Microsoft...
-
freeFTPd是套免費的SFTP SERVER支援22 port SFTP及21port FTP,一般找到免費的都不支援SFTP只有技援FTPS。 之前一直有個困擾在幾台主機安裝後,有幾台重開機後,SFTP SERVER必須手動去啟動,一直以來老是搞不懂為什麼,今天看到一篇文...
沒有留言:
張貼留言