Skip to content

Commit

Permalink
add support for input of various charsets and default to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
zxteloiv committed Mar 1, 2016
1 parent 5cd9499 commit 0e6797a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lolcat
Expand Up @@ -112,11 +112,11 @@ class LolCat(object):
time.sleep(1.0 / options.speed)

def println_plain(self, s, options):
for i, c in enumerate(s):
for i, c in enumerate(s.decode(options.charset)):
rgb = self.rainbow(options.freq, options.os + i / options.spread)
self.output.write(''.join([
self.wrap(self.ansi(rgb)),
c,
c.encode(options.charset),
]))


Expand Down Expand Up @@ -164,6 +164,9 @@ def run():
parser.add_option('-8', action='store_const', dest='mode', const=256,
help='Force 8 bit colour mode')

parser.add_option('-c', '--charset', default='utf-8',
help='Manually set a charset to convert from')

options, args = parser.parse_args()
options.os = random.randint(0, 256) if options.seed == 0 else options.seed
options.mode = options.mode or detect_mode()
Expand Down

0 comments on commit 0e6797a

Please sign in to comment.