Javascript Getting a string into kb format

Posted by Teske on Stack Overflow See other posts from Stack Overflow or by Teske
Published on 2010-05-07T23:56:27Z Indexed on 2010/05/08 1:18 UTC
Read the original article Hit count: 359

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about convert