Skip to content

Instantly share code, notes, and snippets.

@dmilith
Created December 18, 2008 12:06
Show Gist options
  • Select an option

  • Save dmilith/37471 to your computer and use it in GitHub Desktop.

Select an option

Save dmilith/37471 to your computer and use it in GitHub Desktop.
irb(main):003:0> z = "żxczółą".force_encoding "UTF-8"
=> "\305\274xcz\303\263\305\202\304\205"
irb(main):004:0> z.tr "ż", "Ż"
ArgumentError: incompatible character encodings: UTF-8 and ASCII-8BIT
from (irb):5
irb(main):012:0> z.tr "ż".force_encoding("UTF-8"), "Ż".force_encoding("UTF-8")
=> "\305\273xcz\303\263\305\202\304\205"
irb(main):013:0> z
=> "\305\274xcz\303\263\305\202\304\205"
irb(main):014:0> puts z
żxczółą
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment