2010年11月9日 星期二

2010年10月3日 星期日

【C#】Big5 to Unicode

//中文轉為UNICODE

string str = "中文";
string outStr = "";
if (!string.IsNullOrEmpty(str))
{
for (int i = 0; i < str.Length; i++)
{
//將中文轉為10進制整數,然後轉為16進制unicode
outStr += "\\u" + ((int)str[i]).ToString("x");
}
}

//UNICODE轉為中文

string str = "\\u963f\\u53ca";
string outStr = "";
if (!string.IsNullOrEmpty(str))
{
string[] strlist = str.Replace("\\", "").Split('u');
try
{
for (int i = 1; i < strlist.Length; i++)
{
//將unicode轉為10進制整數,然後轉為char中文
outStr += (char)int.Parse(strlist[i], System.Globalization.NumberStyles.HexNumber);
}
}
catch (FormatException ex)
{
outStr = ex.Message;
}
}

【C#】String to Byte

//字串轉 byte[]
public static byte[] GetBytes(string newString, int discarded)
{
discarded = 0;

int byteLength = newString.Length / 2;
byte[] bytes = new byte[byteLength];
string hex;
int j = 0;
for (int i = 0; i < bytes.Length; i++)
{
hex = new String(new Char[] { newString[j], newString[j + 1] });
bytes[i] = HexToByte(hex);
j = j + 2;
}
return bytes;
}

private static byte HexToByte(string hex)
{
if (hex.Length > 2 || hex.Length <= 0)
throw new ArgumentException("hex must be 1 or 2 characters in length");
byte newByte = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);
return newByte;
}

2009年9月17日 星期四

新的生活

最近終於把外宿的地方整理完畢
因為房間算是蠻大的,整理完後卻顯得有點空蕩蕩

住在對面的女生,也養了一隻貓咪
其實我也蠻期待下禮拜阿酷的進駐,不曉得對面的女生願不願意讓阿酷認識她的貓咪

助理的生活,真的很像研究生的生活
事情說多也還可以,說少也還不至於
主要是我的研究部份還沒告一段落,而且也要開始著手於新的計畫
希望我這邊能快點處理好囉

現在要強迫自己每天多背英文單字,之後也加強英聽吧
雖然已經去圖書館借回一些考試相關的書籍,但還沒開始碰

有點糟糕!

新的生活,總是要給自己一些期許:
希望英文能力可以增強
希望計畫部分進行順利
希望每天都要讀書

加油吧!

2009年6月2日 星期二

如何撰寫論文

轉自http://mmdays.com/2008/12/29/start_of_thesis/

好文章,正在寫論文的大家可以看看哦:D

2009年5月22日 星期五

欲速則不達

還有relational information沒做
還有實驗沒完成
還有論文沒寫完


還有...來不及的感覺

加油

2009年5月14日 星期四

Regular Expression

因為寫程式的時候會用到,分享給大家。

Java Regular Expression的學習筆記
http://www.javaworld.com.tw/jute/post/view?bid=20&id=130126&sty=1&tpg=1&age=0