Sha256: 96c878aa1f63c1b59b566b27ee5db238c989e5fcb75c914b8fee1bac6f897bb6

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

class String
  # See Programming Ruby 1.9 - The Pragmatic Programmers’ Guide
  # Figure 17.1. "Encodings and Their Aliases" in the for available encodings.
  def UnicodeToUtf8
    dup.force_encoding("UTF-16LE").encode("UTF-8")
  end

  def UnicodeToUtf8!
    force_encoding("UTF-16LE").encode!("UTF-8")
  end

  def Utf8ToUnicode
    dup.force_encoding("UTF-8").encode("UTF-16LE")
  end

  def Utf8ToUnicode!
    force_encoding("UTF-8").encode!("UTF-16LE")
  end

  def AsciiToUtf8
    dup.force_encoding("ISO-8859-1").encode("UTF-8")
  end

  def AsciiToUtf8!
    force_encoding("ISO-8859-1").encode!("UTF-8")
  end

  def Utf8ToAscii
    dup.force_encoding("UTF-8").encode("ISO-8859-1")
  end

  def Utf8ToAscii!
    force_encoding("UTF-8").encode!("ISO-8859-1")
  end

  def Ucs2ToAscii
    dup.force_encoding("UTF-16LE").encode("ISO-8859-1")
  end

  def Ucs2ToAscii!
    force_encoding("UTF-16LE").encode!("ISO-8859-1")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virt_disk-0.0.1 lib/virt_disk/disk_unicode.rb