Module: PactBroker::Api::Contracts::UTF8Validation
- Extended by:
- UTF8Validation
- Included in:
- UTF8Validation, Resources::BaseResource
- Defined in:
- lib/pact_broker/api/contracts/utf_8_validation.rb
Instance Method Summary collapse
Instance Method Details
#fragment_before_invalid_utf_8_char(string) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/pact_broker/api/contracts/utf_8_validation.rb', line 7 def fragment_before_invalid_utf_8_char(string) string.force_encoding("UTF-8").each_char.with_index do | char, index | if !char.valid_encoding? fragment = index < 100 ? string[0...index] : string[index-100...index] return index + 1, fragment end end nil end |