//private string toText; void Update() { //Debug.LogWarning (labelFrom.text+ "..?;;;?."); if (text != label.text) { string normalize = label.text.Normalize(); text = ""; for (int i = 0; i < normalize.Length; ++i) { int ch = normalize[i]; if (ch >= 0x4e00 && ch <= 0x9fa5) { text += EZTranscoding.Big5Gb2312((char)(ch)); } else if (ch >= ' ' && ch <= '~') { text += (char)(ch); } else { // Debug.LogWarning (ch+ "????"); //Debug.LogWarning ((int)(ch) + "!!!!" ); text += replace; } label.text = text; /* Debug.LogWarning (fromText[i]+ "..??."); * int ch = fromText[i]; * Debug.LogWarning (ch+ "....."); * //Debug.LogWarning (fromText+ "..??.."); * //char ch = fromText[i]; * //Debug.LogWarning (ch+ "....."); * //toText += ch; * /* * if (ch>=0x4e00 && ch<=0x9fa5){ * toText += EZTranscoding.Big5Gb2312(ch); * }else if (ch >= ' ' && ch <= '~'){ * toText += ch; * }else{ * Debug.LogWarning (ch+ "????"); * Debug.LogWarning ((int)(ch) + "!!!!" ); * toText += replace; * } */ } //labelTo.text = toText; } }
/// <summary> /// Validate the specified input. /// </summary> char Validate(string text, char ch) { //return EZTranscoding.Big5Gb2312(ch); // Validation is disabled if (logic == Validation.None || !enabled) { return(ch); } if (logic == Validation.Chinese) { if (ch == 8198) { return(' '); } if (ch >= 0x4e00 && ch <= 0x9fa5) { return(EZTranscoding.Big5Gb2312(ch)); //这个主要是汉字的范围 } if (ch >= 'A' && ch <= 'Z') { return(ch); } if (ch >= 'a' && ch <= 'z') { return(ch); } if (ch >= '0' && ch <= '9') { return(ch); } } else if (logic == Validation.Integer) { // Integer number validation if (ch >= '0' && ch <= '9') { return(ch); } if (ch == '-' && text.Length == 0) { return(ch); } } else if (logic == Validation.Float) { // Floating-point number if (ch >= '0' && ch <= '9') { return(ch); } if (ch == '-' && text.Length == 0) { return(ch); } if (ch == '.' && !text.Contains(".")) { return(ch); } } else if (logic == Validation.Alphanumeric) { // All alphanumeric characters if (ch >= 'A' && ch <= 'Z') { return(ch); } if (ch >= 'a' && ch <= 'z') { return(ch); } if (ch >= '0' && ch <= '9') { return(ch); } } else if (logic == Validation.Username) { // Lowercase and numbers if (ch >= 'A' && ch <= 'Z') { return((char)(ch - 'A' + 'a')); } if (ch >= 'a' && ch <= 'z') { return(ch); } if (ch >= '0' && ch <= '9') { return(ch); } } else if (logic == Validation.Name) { char lastChar = (text.Length > 0) ? text[text.Length - 1] : ' '; if (ch >= 'a' && ch <= 'z') { // Space followed by a letter -- make sure it's capitalized if (lastChar == ' ') { return((char)(ch - 'a' + 'A')); } return(ch); } else if (ch >= 'A' && ch <= 'Z') { // Uppercase letters are only allowed after spaces (and apostrophes) if (lastChar != ' ' && lastChar != '\'') { return((char)(ch - 'A' + 'a')); } return(ch); } else if (ch == '\'') { // Don't allow more than one apostrophe if (lastChar != ' ' && lastChar != '\'' && !text.Contains("'")) { return(ch); } } else if (ch == ' ') { // Don't allow more than one space in a row if (lastChar != ' ' && lastChar != '\'') { return(ch); } } } return((char)0); }