Number of characters: Difference between revisions

Jump to navigation Jump to search
no edit summary
mNo edit summary
No edit summary
Line 37: Line 37:
</table>
</table>


 
== PHP ==
* PHP: [http://php.net/mb_strlen PHP mb_strlen function]
* PHP: [https://www.php.net/manual/en/function.strlen.php strlen] & [http://php.net/mb_strlen PHP mb_strlen function]
<pre>
<pre>
// number of characters
// number of characters
Line 44: Line 44:
echo mb_strlen("《王大文 Dawen》", 'UTF-8') . PHP_EOL; // return 11
echo mb_strlen("《王大文 Dawen》", 'UTF-8') . PHP_EOL; // return 11


// number of bytes
// string length (number of bytes)
echo strlen("狐") . PHP_EOL; // return 3
echo strlen("狐") . PHP_EOL; // return 3
echo strlen("《王大文 Dawen》") . PHP_EOL; // return 21
echo strlen("《王大文 Dawen》") . PHP_EOL; // return 21
</pre>
</pre>
== MySQL ==
* MySQL: [http://www.w3resource.com/mysql/string-functions/mysql-char_length-function.php MySQL CHAR_LENGTH() function]
* MySQL: [http://www.w3resource.com/mysql/string-functions/mysql-char_length-function.php MySQL CHAR_LENGTH() function]
<PRE>
<PRE>
Line 59: Line 61:
</PRE>
</PRE>
* [https://dev.mysql.com/doc/refman/8.0/en/char.html MySQL :: MySQL 8.0 Reference Manual :: 11.4.1 The CHAR and VARCHAR Types] e.g. {{kbd | key=<nowiki>VARCHAR(5)</nowiki>}} or {{kbd | key=<nowiki>CHAR(5)</nowiki>}} means can hold up to 5 characters.
* [https://dev.mysql.com/doc/refman/8.0/en/char.html MySQL :: MySQL 8.0 Reference Manual :: 11.4.1 The CHAR and VARCHAR Types] e.g. {{kbd | key=<nowiki>VARCHAR(5)</nowiki>}} or {{kbd | key=<nowiki>CHAR(5)</nowiki>}} means can hold up to 5 characters.
== Excel ==
* Excel: [https://support.office.com/en-us/article/len-lenb-functions-29236f94-cedc-429d-affd-b5e33d2c67cb LEN, LENB functions] / [https://support.office.com/zh-tw/article/LEN%E3%80%81LENB-%E5%87%BD%E6%95%B8-29236f94-cedc-429d-affd-b5e33d2c67cb LEN、LENB 函數] {{exclaim}} Result of the function {{kbd | key=LENB}} is not the same with the result in other programming language.
* Excel: [https://support.office.com/en-us/article/len-lenb-functions-29236f94-cedc-429d-affd-b5e33d2c67cb LEN, LENB functions] / [https://support.office.com/zh-tw/article/LEN%E3%80%81LENB-%E5%87%BD%E6%95%B8-29236f94-cedc-429d-affd-b5e33d2c67cb LEN、LENB 函數] {{exclaim}} Result of the function {{kbd | key=LENB}} is not the same with the result in other programming language.
<pre>
<pre>

Navigation menu