Example #1
0
 public static bool Validate(string s, bool JP)
 {
     if (JP)
     {
         return(s.All(c => CHAR_TO_JP_RBY.ContainsKey(c) || c == CHAR_FEM_NUM || c == CHAR_MAL_NUM));
     }
     return(!s.Any(c => c > 0xFF || ASCII_To_RBY[c] == 0));
 }
Example #2
0
 public static byte[] GetJPBytes(string s)
 {
     s = s.Replace('♀', (char)CHAR_FEM_NUM).Replace('♂', (char)CHAR_MAL_NUM);
     if (!Validate(s, true))
     {
         s = FixString(s, true);
     }
     if (s == "トレーナー")
     {
         return new[] { ASCII_To_RBY[CHAR_TRAINER], (byte)0x50 }
     }
     ;
     return(s.Select(c => CHAR_TO_JP_RBY.ContainsKey(c) ? CHAR_TO_JP_RBY[c] : ASCII_To_RBY[(byte)c]).Concat(new[] { (byte)0x50 }).ToArray());
 }
Example #3
0
        public static string FixJPString(string s)
        {
            StringBuilder sb = new StringBuilder();

            s = s.Replace('♀', (char)CHAR_FEM_NUM).Replace('♂', (char)CHAR_MAL_NUM);
            foreach (char c in s)
            {
                if (CHAR_TO_JP_RBY.ContainsKey(c) || c == CHAR_FEM_NUM || c == CHAR_MAL_NUM)
                {
                    sb.Append(c);
                }
            }
            return(sb.ToString());
        }