Strange print

V

Valerij KIR

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?
 
R

Robert Klemme

Valerij said:
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
 
E

Eero Saynatkari

Valerij said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,138
Latest member
NevilleLam
Top