Count number of characters: Difference between revisions
mNo edit summary Tag: wikieditor |
Tag: wikieditor |
||
| (One intermediate revision by the same user not shown) | |||
| Line 40: | Line 40: | ||
</table> | </table> | ||
Each Chinese character is approximately 3 bytes in UTF-8 | : [[Image:Owl icon.jpg]] Each Chinese character is approximately 3 bytes in UTF-8 | ||
Common Chinese characters (CJK Unified Ideographs, U+4E00 ~ U+9FFF) are all 3 bytes — for example, "你", "好", "狐", and "象". Characters beyond U+FFFF (outside the Basic Multilingual Plane, BMP<ref>[https://en.wikipedia.org/wiki/Plane_(Unicode) Plane (Unicode) - Wikipedia]</ref>) take 4 bytes. These are mostly rare characters from CJK Extension B (U+20000 and up)<ref>[https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_Extension_B CJK Unified Ideographs Extension B - Wikipedia]</ref>, such as "[https://www.cns11643.gov.tw/wordView.jsp?ID=993142 𤆬]" (U+241AC) and "[https://www.cns11643.gov.tw/wordView.jsp?ID=402472 𠮷]" (U+20BB7). | |||
== How to count characters with PHP == | == How to count characters with PHP == | ||
| Line 173: | Line 175: | ||
* [https://www.ithome.com.tw/voice/131688 Unicode與JavaScript字串 | iThome] | * [https://www.ithome.com.tw/voice/131688 Unicode與JavaScript字串 | iThome] | ||
[[Category:Software]] [[Category:Programming]] [[Category:Data Science]] [[Category:String manipulation]] [[Category:PHP]] [[Category:MySQL]] | [[Category: Software]] | ||
[[Category: Programming]] | |||
[[Category: Data Science]] | |||
[[Category: String manipulation]] | |||
[[Category: PHP]] | |||
[[Category: MySQL]] | |||
[[Category: Revised with LLMs]] | |||