# How to send utf8 data to remote computer in ruby 1.9.2

**URL:** <https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364>\
**Category:** ruby-talk\
**Created:** [17 August 2011 17:54 UTC](https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364 "2011-08-17T17:54:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Petrushin](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alexey\_Petrushin](https://rubytalk.org/u/Alexey_Petrushin)\
**Post date:** [17 August 2011 17:54 UTC](https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364/1 "2011-08-17T17:54:07Z")

</div>

I believe that's not the right way to solve problems of 1% by  
introducing problems to 99% of everyone else.

Why not make the utf-8 default and other encoding possible?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner4](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gavin\_Kistner4](https://rubytalk.org/u/Gavin_Kistner4)\
**Post date:** [17 August 2011 19:15 UTC](https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364/2 "2011-08-17T19:15:50Z")

</div>

That sounds like a good argument. Except…from where do you get your 1% number? Japan is roughly 2% of the world population, but likely a huge portion of Ruby users.

> **···**
>
> On Aug 17, 2011, at 11:54 AM, Alexey Petrushin \<axyd80@gmail.com\> wrote:
> 
> > I believe that's not the right way to solve problems of 1% by  
> > introducing problems to 99% of everyone else.

---

<div class="post-metadata">

**Author:** ![11142](https://avatars.discourse-cdn.com/v4/letter/1/e0b2c6/32.png) [@11142](https://rubytalk.org/u/11142)\
**Post date:** [17 August 2011 19:55 UTC](https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364/3 "2011-08-17T19:55:06Z")

</div>

I did some googling and turns out I was right. Here's an article I  
found: [Ruby 1.9 Encodings: A Primer and the Solution for Rails](http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/)  
- let me cite the relevant part:

> Other languages, such as Java and Python, solve this problem by encodeing every String that enters the language as UTF-8 (or UTF-16). [...]
> 
> However, this solution does not work very well for the Japanese community. For a variety of complicated reasons, Japanese encoding, such as SHIFT-JIS, are not considered to losslessly encode into UTF-8. As a result, Ruby has a policy of not attempting to simply encode any inbound String into UTF-8.

The article itself is actually a pretty interesting read.

Also, Alexey, that 1% you pulled out of nowhere is certainly wrong.  
Just look at, say, the official Ruby language issues tracker -  
[Issues - Ruby Issue Tracking System](http://redmine.ruby-lang.org/issues/) - and count issues written in  
Japanese, or by Japanese people. There aren't many here, since this is  
an English-language list.

-- Matma Rex

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [18 August 2011 15:17 UTC](https://rubytalk.org/t/how-to-send-utf8-data-to-remote-computer-in-ruby-1-9-2/63364/4 "2011-08-18T15:17:44Z")

</div>

Bartosz Dziewoński wrote in post #1017168:

> - let me cite the relevant part:
> 
> > Other languages, such as Java and Python, solve this problem by encodeing every
> 
> String that enters the language as UTF-8 (or UTF-16). [...]
> 
> > However, this solution does not work very well for the Japanese community. For

a

> variety of complicated reasons, Japanese encoding, such as SHIFT-JIS,  
> are not  
> considered to losslessly encode into UTF-8. As a result, Ruby has a  
> policy of not  
> attempting to simply encode any inbound String into UTF-8.

Except that even ruby 1.9 cannot handle SHIFT-JIS (it's a stateful  
encoding)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
