ログインしてさらにmixiを楽しもう

コメントを投稿して情報交換!
更新通知を受け取って、最新情報をゲット!

C#コミュのstring manipulation in C#

  • mixiチェック
  • このエントリーをはてなブックマークに追加
すみません。日本語はまだよく分かりません。

So, I hope you dont mind me asking in english.

I'm codding a frontend to EDICT using c#/.net and I'm wondering how I can manipulate strings that containt japanese text.

For example,
What is the best way to test if a given character is katakana/hiragana/romanji/kanji?
What is the best way to test if a string contains kanji or not?

Thanx a lot (and excuse for using english if that's inappropriate for this community)

コメント(4)

static bool IsKatakana(char ch)
{
return 0x30A0 <= ch && ch <= 0x30FF;
}

static bool IsHiragana(char ch)
{
return 0x3040 <= ch && ch <= 0x309F;
}

static bool IsKanji(char ch)
{
return 0x4E00 <= ch && ch <= 0x9FFF;
}

static void Main(string[] args)
{
// Test if a given character is katakana/hiragana/romanji/kanji.
Debug.Assert(IsKatakana('ア'));

Debug.Assert(IsHiragana('あ'));

Debug.Assert(IsKanji('亜'));

// Test if a string contains kanji or not.
bool containsKanji = new List<char>("Contains 漢字").Exists(IsKanji);
Debug.Assert(containsKanji);
}
どうもありがとうございます :−)

ログインすると、みんなのコメントがもっと見れるよ

mixiユーザー
ログインしてコメントしよう!

C# 更新情報

C#のメンバーはこんなコミュニティにも参加しています

星印の数は、共通して参加しているメンバーが多いほど増えます。

人気コミュニティランキング