Javascript Getting a string into kb format
- by Teske
I am new to javascript and I just wanted to convert a string into a format that a person like me can read. Here is an example of what I am trying to do...
string2size(string){
//some awesome coding I have no clue how to make
return awesomeAnswer
}
now the return should give me something like 56 bytes or 12kb or 1mb depending how much the string is.
so if the string is...
string = "there was an old woman who lived in a shoe";
then string2size(string) should return something like 3kb.
Now I know there has been a utf8 talk and I wouldn't object to and addition of that to the function.
I have tried google and Yahoo searches but they talk of using php but I really need it for javascript. I do thank anyone for their time.
-Teske