While working on a multilingual site (with Japanese and Chinese languages ) where users were allowed to enter characters in regional language. I had this requirement to validate user inputs based on memory taken by each character as character can be single byte, double byte or triple byte.
I used following solution for this as mentioned in the answer.
Characters can be single byte ,double byte, triple byte and so on. Single byte follows in a particular range. Same thing is true for other characters. Based on this I have created following functions that will calculate the size of a string on the basis of memory
So above function can be modified to find out whether a function is single byte or multi-bytes.
Following js fiddle determines the size of entered text in terms of memory.
http://jsfiddle.net/paraselixir/d83oaa3v/5/
so if string has x characters and memory size is y so if x === y then all characters are single bytes if 2*x === y then all characters are double bytes otherwise string is combination of single and double/multi bytes.