# File lib/puppet/util/puppetdb/char_encoding.rb, line 154 def self.ruby18_handle_multibyte_char(result_str, byte, str, i, char_len, strip = true) # keeping an array of bytes for now because we need to do some # bitwise math on them. char_additional_bytes = [] # If we don't have enough bytes left to read the full character, we # put on a replacement character and bail. if i + (char_len - 1) > str.length result_str.concat(Utf8ReplacementChar) unless strip return end # we've already read the first byte, so we need to set up a range # from 0 to (n-2); e.g. if it's a 2-byte char, we will have a range # from 0 to 0 which will result in reading 1 more byte (0..char_len - 2).each do |x| char_additional_bytes << get_byte(str, i + x) end if (is_valid_multibyte_suffix(byte, char_additional_bytes)) result_str << byte result_str.concat(char_additional_bytes.pack("c*")) else result_str.concat(Utf8ReplacementChar) unless strip end end