文字列がカタカナか判定する方法
VB.NET
Public Shared Function IsFullwidthKatakana(ByVal c As Char) As Boolean
'カタカナならTrue
Return (ChrW(&H30A0) <= c AndAlso c <= ChrW(&H30FF)) OrElse _
(ChrW(&H31F0) <= c AndAlso c <= ChrW(&H31FF)) OrElse _
(ChrW(&H3099) <= c AndAlso c <= ChrW(&H309C))
End Function
作って覚える Visual Basic 2010 Express入門
C#
public static bool IsFullwidthKatakana(char c)
{
//カタカナならTrue
return ('\u30A0' <= c && c <= '\u30FF')
|| ('\u31F0' <= c && c <= '\u31FF')
|| ('\u3099' <= c && c <= '\u309C');
}
作って覚える Visual Basic 2010 Express入門