For multiline RichEdit controls, CRichEditCtrl provides a function to get the length of each line of characters: LineLength ()
The definition is as follows:
Retrieves the length of a line with rich edit control. int linelength (int nline =-1) const;
Length Fetch string Lengths
The code is as follows
Copy Code
In Chinese and English, one character is equivalent to 2 characters
Example 1
The code is as follows
Copy Code
In PHP, we all know that there are special MB_SUBSTR and Mb_strlen functions that can intercept and compute the length of Chinese, but because these functions are not PHP's core functions, they are often not open. Of course, if you are using your
Write Functions in C language to implement strlen's function of calculating the string lengthThis article introduces three methods: 1. Cyclic notation (set a counter ). 2. Recursive Method, (function call itself for calculation) 3. pointer-pointer
Copy codeThe Code is as follows:// Obtain the length of the string in bytesFunction len (s ){S = String (s );Return s. length + (s. match (/[^ \ x00-\ xff]/g) | ""). length; // Add the length of the matched fullwidth characters}
Function limit (obj,
In php, when we need to determine the length of a string, we first think of the strlen () function. Good, strlen () returns the length of the string, so there is no problem. However, from the perspective of php program optimization, programmers who
A few ways to get the length of a string
-Use bytes. COUNT () statistics
-Use strings. COUNT () statistics
-Convert string to []rune after calling Len function for statistics
-Use UTF8. Runecountinstring () Statistics
Cases:
Experienced programmers found that php judges the length of a string, and isset () is faster than strlen (), and the execution efficiency is higher.That is:Copy codeThe Code is as follows:$ Str = 'aaaaa ';If (strlen ($ str)> 6)VSIf (! Isset ($ str {6
[Cpp]/** Copyright and version statement of the program section * Copyright (c) 2012, student * All rightsreserved from computer College of Yantai University. * file name: fun. cpp * Author: Li Meng * Completion Date: July 15, December 19, 2012 *
Length: the length of a calculated field. A Chinese character is counted as three characters. A number or letter is counted as one character.The return value of CHAR_LENGTH (str) is the length of the str string, measured in characters. A multi-byte
In the development of PHP, because of our country's language environment problems, so we often need to deal with the Chinese. In PHP, we all know that there are special MB_SUBSTR and Mb_strlen functions that can intercept and calculate the length of
This is a creation in
Article, where the information may have evolved or changed.
A few ways to get the length of a string
-Use bytes. COUNT () statistics-use strings. COUNT () Statistics-Converts a string to []rune] and calls the Len function for
The following code can be used to determine the length of a Chinese string in a mixed string. because php does not support Chinese computing, we have customized a function. The following code can be used to determine the length of a Chinese string
The strlen () PHPstrlen () function defines and uses the strlen () function to return the length of the string. Syntax strlen (string) parameter: string description: required. Specifies the string to be checked. The code is as follows... strlen
Before using this method, go to php. enable php_mbstring.dll extension in ini and remove the semicolon before extension. many methods to intercept Chinese strings cannot extract the desired characters by the number of Chinese characters. the
Experienced programmers found that PHP judged the length of the string, using Isset () at a faster speed than strlen () and performing more efficiently.
namely:
Copy CodeThe code is as follows:
$str = ' aaaaaa ';
if (strlen ($STR) > 6)
Vs
if
Here is the code I wrote to enable the segmentation of Chinese and English mixed characters:
';p rint_r ($r); Echo '';? >
Operation Result:
Array ( [0] = = I love beijing [1] = 3 I love [2] = + Sea-I love [3] = Xian [4] = Ggan [5] = g)
0)
The Chinese string for UTF-8 is three bytes
Code UTF-8
echo strlen (' Test text a Test text ');
Echo '-';
echo mb_strlen (' Test text a Test text ', ' utf-8 ');
?>
Output: 25-9
The Chinese string for GB2312 is two bytes
Code GB2312
echo strlen (
Sometimes we encounter the problem of too many characters in the title of the article during page display. We need to take a certain length and use the ellipsis later. This can be implemented using css. However, the Firefox browser does not display
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.