Forum: Ruby String utf8 size in kilobytes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel W. (Guest)
on 2006-01-05 13:05
I have a mimemessage in a string.
This string is utf8, i would like to know the size of this string.
String.size gives me the length in characters, but i need the size in kb
or bytes
Andreas S. (Guest)
on 2006-01-05 14:44
daniel wijnands wrote:
> I have a mimemessage in a string.
> This string is utf8, i would like to know the size of this string.
> String.size gives me the length in characters, but i need the size in kb
> or bytes

String#size returns the size in bytes. String#jsize returns the number
of characters (with require 'jcode').
Daniel W. (Guest)
on 2006-01-05 14:47
Thanks, then my method is valid, i want to know the bytes, so that's
fine :)

Andreas S. wrote:
> daniel wijnands wrote:
>> I have a mimemessage in a string.
>> This string is utf8, i would like to know the size of this string.
>> String.size gives me the length in characters, but i need the size in kb
>> or bytes
>
> String#size returns the size in bytes. String#jsize returns the number
> of characters (with require 'jcode').
This topic is locked and can not be replied to.