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.
C14805404d3f08ba9b1f6ad93c01615f?d=identicon&s=25 Daniel Wijnands (dewie)
on 2006-01-05 12: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
3a83969376c805ef5b6042191fdb0ff3?d=identicon&s=25 Andreas S. (andreas)
on 2006-01-05 13: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').
C14805404d3f08ba9b1f6ad93c01615f?d=identicon&s=25 Daniel Wijnands (dewie)
on 2006-01-05 13: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.