Sha256: d9e5e8020cef91a328ac1e8987c35fd8ca228d45356b50604fb12b583df589ba

Contents?: true

Size: 274 Bytes

Versions: 31

Compression:

Stored size: 274 Bytes

Contents

#! /usr/bin/env ruby
# Replaces invalid utf-8 characters with �.
#
# Usage:
# $ cat some_file | string_encoder

while input = gets
  if input.to_s.valid_encoding?
    puts input
  else
    puts input.encode('UTF-8', 'binary', invalid: :replace, undef: :replace)
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ohloh_scm-2.4.9 bin/string_encoder
ohloh_scm-2.4.8 bin/string_encoder
ohloh_scm-2.4.7 bin/string_encoder
ohloh_scm-2.4.6 bin/string_encoder
ohloh_scm-2.4.5 bin/string_encoder
ohloh_scm-2.4.4 bin/string_encoder
ohloh_scm-2.4.3 bin/string_encoder
ohloh_scm-2.4.1 bin/string_encoder
ohloh_scm-2.4.0 bin/string_encoder
ohloh_scm-2.3.5 bin/string_encoder
ohloh_scm-2.3.4 bin/string_encoder
ohloh_scm-2.3.2 bin/string_encoder
ohloh_scm-2.3.1 bin/string_encoder
ohloh_scm-2.3.0 bin/string_encoder
ohloh_scm-2.2.13 bin/string_encoder
ohloh_scm-2.2.12 bin/string_encoder
ohloh_scm-2.2.11 bin/string_encoder
ohloh_scm-2.2.10 bin/string_encoder
ohloh_scm-2.2.9 bin/string_encoder
ohloh_scm-2.2.8 bin/string_encoder