+def ljust(s, n, c):
+ """ Needed for Python 2.3 compatibility """
+ return s + (n-len(s))*c
+
+if sys.byteorder == "little":
+ def utf16net(s):
+ """ Encodes to utf-16 and ensures network byte order. Strips the BOM """
+ a = array.array("h", s.encode("utf-16")[2:])
+ a.byteswap()
+ return a.tostring()
+else:
+ def utf16net(s):
+ """ Encodes to utf-16 and ensures network byte order. Strips the BOM """
+ return s.encode("utf-16")[2:]
+