comparison multimerge.py @ 47:a8fdecd4be61

Fixes to Unicode handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jul 2016 17:55:14 +0300
parents 51c87abe5a1e
children cc30383f5f0d
comparison
equal deleted inserted replaced
46:51c87abe5a1e 47:a8fdecd4be61
34 34
35 ## Wrapper for print() that does not break when redirecting stdin/out 35 ## Wrapper for print() that does not break when redirecting stdin/out
36 ## because of piped output not having a defined encoding. We default 36 ## because of piped output not having a defined encoding. We default
37 ## to UTF-8 encoding in output here. 37 ## to UTF-8 encoding in output here.
38 def gcm_print(smsg): 38 def gcm_print(smsg):
39 gcm_msgbuf.append(smsg.encode("UTF-8")) 39 gcm_msgbuf.append(smsg)
40 if sys.stdout.encoding != None: 40 if sys.stdout.encoding != None:
41 print(smsg.encode(sys.stdout.encoding)) 41 print(smsg.encode(sys.stdout.encoding))
42 else: 42 else:
43 print(smsg.encode("UTF-8")) 43 print(smsg.encode("UTF-8"))
44 44
65 ## Debug messages 65 ## Debug messages
66 def gcm_debug(smsg): 66 def gcm_debug(smsg):
67 if cfg.debug: 67 if cfg.debug:
68 gcm_print(u"DBG: "+ smsg) 68 gcm_print(u"DBG: "+ smsg)
69 else: 69 else:
70 gcm_msgbuf.append(u"DBG: "+ smsg.encode("UTF-8")) 70 gcm_msgbuf.append(u"DBG: {0}".format(smsg))
71 71
72 72
73 ## Handler for SIGINT signals 73 ## Handler for SIGINT signals
74 def gcm_signal_handler(signal, frame): 74 def gcm_signal_handler(signal, frame):
75 gcm_print("\nQuitting due to SIGINT / Ctrl+C!") 75 gcm_print("\nQuitting due to SIGINT / Ctrl+C!")