# String utf8 size in kilobytes

**URL:** <https://www.ruby-forum.com/t/string-utf8-size-in-kilobytes/90059>\
**Category:** Ruby\
**Created:** [January 5, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/string-utf8-size-in-kilobytes/90059 "2006-01-05T12:05:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [January 5, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/string-utf8-size-in-kilobytes/90059/1 "2006-01-05T12:05:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [January 5, 2006, 1:44pm UTC](https://www.ruby-forum.com/t/string-utf8-size-in-kilobytes/90059/2 "2006-01-05T13:44:58Z")

</div>

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’).

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [January 5, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/string-utf8-size-in-kilobytes/90059/3 "2006-01-05T13:47:47Z")

</div>

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’).
