Method: JavaProperties::Encoding.encode

Defined in:
lib/java_properties/encoding.rb

.encode(string) ⇒ Object

Encodes a string by escaping special characters (n, t, etc.), delimiters ( =, :) and UTF-8 characters.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/java_properties/encoding.rb', line 14

def self.encode string
  # Replace special chars with proper \n escaped characters
  string = SpecialChars.encode(string)
  
  # Replace unescaped delimiters with proper \n escaped characters
  string = Delimiters.encode(string)
  
  # Replace UTF-8 bytes with \uXXXX encoding
  string = Utf8.encode(string)
  
  string
end