http://blog.csdn.net/ns_code/article/details/14162087Http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html8. ExampleBelow, give an example.Open Notepad program Notepad.exe, create a new text file, the content is a "strict" word, followed by Ansi,unicode,unicode big endian and UTF-8 encoding method to save.Then, use the "hex feature" in the text editing software UltraEdit to see how the file is encoded internally.1) ANSI: The encoding of the file is two bytes "D1 CF", which is the "
Link: Click to open linkThe main idea:The number of characters in the input string.The idea:In doing this problem I do not know how to store the man in the computer, after looking for information to know that Chinese characters are not ascιι code, Chinese characters in the computer using two bytes to store, and the highest bit of each byte is 1, and in the computer, the highest bit of bytes is the sign bit, 1 is negative, Therefore, the Chinese character machine code every byte of the decimal is
The first approach:
Load the Encode module, if you need to install this module
Example code:
Copy CodeThe code is as follows:
$str =decode ("gb2312", $names [$index]);
@chars =split (//, $STR);
foreach (@chars)
{
$char =encode ("gb2312", $_);
Print "one WORD: $char \ n";
}
The second approach:
Chinese characters are accounted for 2 bytes, so you can use the following statement directly to get the kanji, the code is as follows:
@chars =split (//,
Rt
To verify the username, it contains only numbers, letters, underscores, kanji, and is required to be detected even if the order is scrambled.
Reply to discussion (solution)
Rule string:/^\w+$/uFor Utf-8 character set, non-utf-8, re-use of utf-8
'/^[\x7f-\xffa-za-z0-9_]+$/'
$s = '% '; Var_dump (Preg_match ('/^\w+$/u ', $s)); Int (0) var_dump (preg_match ('/^[\x7f-\xffa-za-z0-9_]+$/', $s)); Int (1)
Full-width punctuation is not a Chinese c
A small point of knowledge, but also the interview was asked, so summarize:Enter a character char str1. Use ASCII code to judge, English is 0-127, Chinese character >127if ((int) str>127)---> is kanji2. Using the Unicode encoding range of Chinese characters, the Unicode encoding of Chinese characters is 4E00-9FBBif (STR>=4E00STR3. Judging with regular expressionsif (Regex.IsMatch (str. ToString (), @ "[\u4e00-\u9fbb]+$"))--->true, is the kanjiHow to judge a character in C # as a
Microsoft.International.Formatters.EastAsiaNumericFormatter (), "{0:ln}", 1234567890.45);--Convert numbers to currencies (pick up the Hundred billion San Wu to pick up the land million seven Ba Bai Jiu pick point Wu)1 string temp_7 = string. Format (New Microsoft.International.Formatters.EastAsiaNumericFormatter (), "{0:LC}", 1234567890.45);Instance code:
12345678910111213141516171819202122
//简体/繁体切换string temp_1 = ChineseConverter.Convert("中国人", ChineseConversionDirection.Trad
PHP converts the number 1.1 billion to a kanji representation, such as 150 turns 150
Directly on the instance
Written to hundreds of billions.
/**
* @author ja Ode* Replace the number 1.1 billion with Chinese characters, such as:123-> 123* @param [num] $num [number]* @return [string] [string]*/function Numtoword ($num){$chiNum = Array (' 0 ', ' one ', ' two ', ' three ', ' four ', ' V ', ' VI ', ' VII ', ' VIII ', ' IX ');$chiUni = Array (' ', ' ten
Text processing often determines whether a string is a letter, a number, or a Chinese character, and the Python str module provides methods but does not support Unicode, so imitating the Str method enables the kanji/digit/alphanumeric method of Unicode strings, as well as full-width half-width conversions.
#!/usr/bin/env python #-*-coding:utf-8-*-import sys #set default encoding as UTF-8 reload (SYS) Sys.setdefaultencodi Ng (' utf-8 ') #judge a cha
Custom View Exercise-Kanji keyboard
Practice Source
Android custom keyboard final effect diagram of Chinese character keyboard
Basic Knowledge
The following is excerpted from the above article
First, soft keyboard introduction
The implementation of the soft keyboard is mainly used in the system of two classes: Keyboard and Keyboardview.Keyboard class source code is introduced: Listener for virtual keyboard events.Keyboardview class source code is in
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.