# Strange print

**URL:** <https://www.ruby-forum.com/t/strange-print/99367>\
**Category:** Ruby\
**Created:** [January 31, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/strange-print/99367 "2006-01-31T16:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![python](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@python](https://www.ruby-forum.com/u/python)\
**Post date:** [January 31, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/strange-print/99367/1 "2006-01-31T16:09:21Z")

</div>

Hi all!  
I have some text in russian. Then I’ve print it with puts I saw beatiful  
text, but then use p operator text is “\353\317\314\314\305\304\326”.  
How can I solve problem, because when using iconv the problem is same?

---

<div class="post-metadata">

**Author:** ![python](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@python](https://www.ruby-forum.com/u/python)\
**Post date:** [January 31, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/strange-print/99367/2 "2006-01-31T19:41:33Z")

</div>

Valerij Kirjanov wrote:

> Hi all!  
> I have some text in russian. Then I’ve print it with puts I saw beatiful  
> text, but then use p operator text is “\353\317\314\314\305\304\326”.  
> How can I solve problem, because when using iconv the problem is same?

The difference between puts obj and p obj is that the  
former uses obj.to\_s and the latter obj.inspect. Is  
there a specific reason why you need to use p instead  
of puts or did I misunderstand you?

E

---

<div class="post-metadata">

**Author:** ![python](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@python](https://www.ruby-forum.com/u/python)\
**Post date:** [February 1, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/strange-print/99367/3 "2006-02-01T23:46:34Z")

</div>

Valerij KIR wrote:

> Hi all!  
> I have some text in russian. Then I’ve print it with puts I saw  
> beatiful text, but then use p operator text is  
> “\353\317\314\314\305\304\326”. How can I solve problem, because when  
> using iconv the problem is same?

p uses String#inspect which I believe will always print something that  
can  
be safely interpreted as a Ruby string on 7 bit ASCII. You should use  
puts instead of p - p is really rather a debugging / inspection untility  
but not meant for normal program output (IMHO).

Kind regards

```
robert
```
