Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created March 8, 2014 06:59
Show Gist options
  • Select an option

  • Save baba-s/9426561 to your computer and use it in GitHub Desktop.

Select an option

Save baba-s/9426561 to your computer and use it in GitHub Desktop.
public static partial class StringExtensions
{
/// <summary>
/// 1バイト文字で構成された文字列かどうかを確認します
/// </summary>
/// <param name="str">確認対象の文字列</param>
/// <returns>1バイト文字のみで構成された文字列の場合 true</returns>
public static bool IsOneByteStr(string str)
{
var bytes = System.Text.Encoding.GetEncoding(932).GetBytes(str);
return bytes.Length == str.Length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment