ZXing.QrCode.Internal.Encoder.isOnlyDoubleByteKanji C# (CSharp) Метод

isOnlyDoubleByteKanji() приватный статический Метод

private static isOnlyDoubleByteKanji ( String content ) : bool
content String
Результат bool
      private static bool isOnlyDoubleByteKanji(String content)
      {
         byte[] bytes;
         try
         {
            bytes = Encoding.GetEncoding("Shift_JIS").GetBytes(content);
         }
         catch (Exception )
         {
            return false;
         }
         int length = bytes.Length;
         if (length % 2 != 0)
         {
            return false;
         }
         for (int i = 0; i < length; i += 2)
         {


            int byte1 = bytes[i] & 0xFF;
            if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB))
            {

               return false;
            }
         }
         return true;
      }

Usage Example

Пример #1
0
 private static bool isDoubleByteKanji(char c)
 {
     return(Encoder.isOnlyDoubleByteKanji(new String(new[] { c })));
 }