awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.08k stars 454 forks source link

ap escapes unicode with \uXXXX #118

Open guai opened 11 years ago

michaeldv commented 11 years ago

Could you elaborate what's wrong with that and what would you rather expect?

coezbek commented 7 years ago

I guess the issue is, how not to escape unicode. It might be useful for debugging at some points but if it is your primary character encoding (think Chinese?), then you would just want unicode characters to stay that way.

gerrywastaken commented 7 years ago

@guai @coezbek

Under the hood we use Ruby's inspect method which respects the value of the default external encoding when deciding how to generate output. (see: https://ruby-doc.org/core-2.3.3/Object.html#method-i-inspect)

require 'awesome_print'

Encoding.default_external = Encoding::ISO_8859_1
ap '我爱北京' # output: "\u6211\u7231\u5317\u4EAC"

Encoding.default_external = Encoding::UTF_8
ap '我爱北京' # output: "我爱北京"

Thank for following up @coezbek. I had not seen this issue till now. Please let me know if this solves the issue. :)