Count number of characters: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
Line 39: Line 39:
</table>
</table>


== PHP ==
== How to count characters with PHP ==
* PHP: [https://www.php.net/manual/en/function.strlen.php strlen] & [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]


Line 60: Line 60:
</pre>
</pre>


== MySQL ==
== How to count characters with 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 74: Line 74:




== SQLite ==
== How to count characters with SQLite ==
[https://www.sqlitetutorial.net/sqlite-functions/sqlite-length/#targetText=SQLite%20Length,returns%20the%20number%20of%20bytes. Length] function
[https://www.sqlitetutorial.net/sqlite-functions/sqlite-length/#targetText=SQLite%20Length,returns%20the%20number%20of%20bytes. Length] function
<PRE>
<PRE>
Line 81: Line 81:
</PRE>
</PRE>


== Excel ==
== How to count characters with 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>
Line 96: Line 96:
* [https://stackoverflow.com/questions/5290182/how-many-bytes-does-one-unicode-character-take string - How many bytes does one Unicode character take? - Stack Overflow]
* [https://stackoverflow.com/questions/5290182/how-many-bytes-does-one-unicode-character-take string - How many bytes does one Unicode character take? - Stack Overflow]


== BASH ==
== How to count characters with BASH ==
Step1: Using [https://www.computerhope.com/unix/uwc.htm Linux wc command]
Step1: Using [https://www.computerhope.com/unix/uwc.htm Linux wc command]
<pre>
<pre>
Line 117: Line 117:




== Python ==
== How to count characters with Python ==
Using the [https://docs.python.org/3/library/functions.html#len len()] function<ref>[https://stackoverflow.com/questions/30686701/python-get-size-of-string-in-bytes Python : Get size of string in bytes - Stack Overflow]</ref>. Try it on [https://replit.com/@planetoid/lenth-of-string#main.py replit].
Using the [https://docs.python.org/3/library/functions.html#len len()] function<ref>[https://stackoverflow.com/questions/30686701/python-get-size-of-string-in-bytes Python : Get size of string in bytes - Stack Overflow]</ref>. Try it on [https://replit.com/@planetoid/lenth-of-string#main.py replit].


Line 140: Line 140:




== JavaScript ==
== How to count characters with JavaScript ==
Using the [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length length()] function and [https://developer.mozilla.org/en-US/docs/Web/API/Blob Blob] object <ref> [https://stackoverflow.com/questions/2219526/how-many-bytes-in-a-javascript-string How many bytes in a JavaScript string? - Stack Overflow]</ref>.
Using the [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length length()] function and [https://developer.mozilla.org/en-US/docs/Web/API/Blob Blob] object <ref> [https://stackoverflow.com/questions/2219526/how-many-bytes-in-a-javascript-string How many bytes in a JavaScript string? - Stack Overflow]</ref>.


Anonymous user

Navigation menu