Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rubymotion/encodings.rb,
lib/kramdown/compatibility.rb
Overview
As of RubyMotion 3.5, the String.encode method will always gives a
RuntimeError: this operation cannot be performed with encoding `UTF-8'
because Apple's ICU does not support it
However, String.force_encoding seems to work. However, that would support unsafe conversions. For now, most of our input is already properly encoded as utf-8, so there is no need to run the actual encode. Check for this.
Instance Method Summary collapse
- #encode(encoding) ⇒ Object
- #encode!(encoding) ⇒ Object
- #end_with?(str) ⇒ Boolean
-
#orig_encode ⇒ Object
——————————————————————————.
-
#orig_encode! ⇒ Object
——————————————————————————.
- #start_with?(str) ⇒ Boolean
Instance Method Details
#encode(encoding) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rubymotion/encodings.rb', line 17 def encode(encoding) return self.dup if self.encoding.to_s == encoding.to_s if self.encoding.to_s == 'US-ASCII' && encoding.to_s == 'UTF-8' self.dup.force_encoding('UTF-8') else orig_encode(encoding) end end |
#encode!(encoding) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/rubymotion/encodings.rb', line 28 def encode!(encoding) return self if self.encoding.to_s == encoding.to_s if self.encoding.to_s == 'US-ASCII' && encoding.to_s == 'UTF-8' self.force_encoding('UTF-8') else orig_encode!(encoding) end end |
#end_with?(str) ⇒ Boolean
29 30 31 |
# File 'lib/kramdown/compatibility.rb', line 29 def end_with?(str) self[-str.length, str.length] == str end |
#orig_encode ⇒ Object
16 |
# File 'lib/rubymotion/encodings.rb', line 16 alias_method :orig_encode, :encode |
#orig_encode! ⇒ Object
27 |
# File 'lib/rubymotion/encodings.rb', line 27 alias_method :orig_encode!, :encode! |
#start_with?(str) ⇒ Boolean
26 27 28 |
# File 'lib/kramdown/compatibility.rb', line 26 def start_with?(str) self[0, str.length] == str end |