py23 introduce byteord() and use it
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index c41370d..365d6a1 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -203,7 +203,7 @@
 def _data2binary(data, numBits):
 	binaryList = []
 	for curByte in data:
-		value = ord(curByte)
+		value = byteord(curByte)
 		numBitsCut = min(8, numBits)
 		for i in range(numBitsCut):
 			if value & 0x1:
@@ -243,7 +243,7 @@
 def _reverseBytes(data):
 	if len(data) != 1:
 		return "".join(map(_reverseBytes, data))
-	byte = ord(data)
+	byte = byteord(data)
 	result = 0
 	for i in range(8):
 		result = result << 1
@@ -522,12 +522,12 @@
 			else:
 				numBitsCut = endBit - curBit
 			curByte = _reverseBytes(self.imageData[firstByteLoc])
-			firstHalf = ord(curByte) >> cutPoint
+			firstHalf = byteord(curByte) >> cutPoint
 			firstHalf = ((1<<numBitsCut)-1) & firstHalf
 			newByte = firstHalf
 			if firstByteLoc < secondByteLoc and secondByteLoc < len(self.imageData):
 				curByte = _reverseBytes(self.imageData[secondByteLoc])
-				secondHalf = ord(curByte) << numBitsCut
+				secondHalf = byteord(curByte) << numBitsCut
 				newByte = (firstHalf | secondHalf) & ((1<<numBits)-1)
 			dataList.append(bytechr(newByte))
 
@@ -559,7 +559,7 @@
 					numBitsCut = 8 - cutPoint
 				else:
 					numBitsCut = endBit - curBit
-				curByte = ord(curByte)
+				curByte = byteord(curByte)
 				firstByte = curByte & ((1<<numBitsCut)-1)
 				ordDataList[firstByteLoc] |= (firstByte << cutPoint)
 				if firstByteLoc < secondByteLoc and secondByteLoc < numBytes:
diff --git a/Lib/fontTools/ttLib/tables/M_E_T_A_.py b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
index 2a0da8f..0ec42a9 100644
--- a/Lib/fontTools/ttLib/tables/M_E_T_A_.py
+++ b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
@@ -238,6 +238,7 @@
 	def __repr__(self):
 		return "GlyphRecord[ glyphID: " + str(self.glyphID) + ", nMetaEntry: " + str(self.nMetaEntry) + ", offset: " + str(self.offset) + " ]"
 
+# XXX The following two functions are really broken around UTF-8 vs Unicode
 
 def mapXMLToUTF8(string):
 	uString = unicode()
@@ -258,7 +259,7 @@
 			
 			uString = uString + unichr(eval('0x' + valStr))
 		else:
-			uString = uString + unichr(ord(string[i]))
+			uString = uString + unichr(byteord(string[i]))
 		i = i +1
 			
 	return uString.encode('utf8')
@@ -268,7 +269,7 @@
 	uString = string.decode('utf8')
 	string = bytes()
 	for uChar in uString:
-		i = ord(uChar)
+		i = byteord(uChar)
 		if (i < 0x80) and (i > 0x1F):
 			string = string + bytechr(i)
 		else:
diff --git a/Lib/fontTools/ttLib/tables/S_I_N_G_.py b/Lib/fontTools/ttLib/tables/S_I_N_G_.py
index 498de6b..707bab9 100644
--- a/Lib/fontTools/ttLib/tables/S_I_N_G_.py
+++ b/Lib/fontTools/ttLib/tables/S_I_N_G_.py
@@ -29,20 +29,20 @@
 	def decompile(self, data, ttFont):
 		dummy, rest = sstruct.unpack2(SINGFormat, data, self)
 		self.uniqueName = self.decompileUniqueName(self.uniqueName)
-		self.nameLength = ord(self.nameLength)
+		self.nameLength = byteord(self.nameLength)
 		assert len(rest) == self.nameLength
 		self.baseGlyphName = rest
 		
 		rawMETAMD5 = self.METAMD5
-		self.METAMD5 = "[" + hex(ord(self.METAMD5[0]))
+		self.METAMD5 = "[" + hex(byteord(self.METAMD5[0]))
 		for char in rawMETAMD5[1:]:
-			self.METAMD5 = self.METAMD5 + ", " + hex(ord(char))
+			self.METAMD5 = self.METAMD5 + ", " + hex(byteord(char))
 		self.METAMD5 = self.METAMD5 + "]"
 		
 	def decompileUniqueName(self, data):
 		name = ""
 		for char in data:
-			val = ord(char)
+			val = byteord(char)
 			if val == 0:
 				break
 			if (val > 31) or (val < 128):
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index 4c306ba..4e1d929 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -426,11 +426,11 @@
 		yFormat = ">" # big endian
 		i = j = 0
 		while True:
-			flag = ord(data[i])
+			flag = byteord(data[i])
 			i = i + 1
 			repeat = 1
 			if flag & flagRepeat:
-				repeat = ord(data[i]) + 1
+				repeat = byteord(data[i]) + 1
 				i = i + 1
 			for k in range(repeat):
 				if flag & flagXShort:
@@ -971,7 +971,7 @@
 def reprflag(flag):
 	bin = ""
 	if isinstance(flag, str):
-		flag = ord(flag)
+		flag = byteord(flag)
 	while flag:
 		if flag & 0x01:
 			bin = "1" + bin
diff --git a/Lib/fontTools/ttLib/tables/_h_d_m_x.py b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
index 4b0875c..802227e 100644
--- a/Lib/fontTools/ttLib/tables/_h_d_m_x.py
+++ b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
@@ -18,11 +18,11 @@
 		dummy, data = sstruct.unpack2(hdmxHeaderFormat, data, self)
 		self.hdmx = {}
 		for i in range(self.numRecords):
-			ppem = ord(data[0])
-			maxSize = ord(data[1])
+			ppem = byteord(data[0])
+			maxSize = byteord(data[1])
 			widths = {}
 			for glyphID in range(numGlyphs):
-				widths[glyphOrder[glyphID]] = ord(data[glyphID+2])
+				widths[glyphOrder[glyphID]] = byteord(data[glyphID+2])
 			self.hdmx[ppem] = widths
 			data = data[self.recordSize:]
 		assert len(data) == 0, "too much hdmx data"
diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
index a95f50f..3ef1717 100644
--- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py
+++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
@@ -134,7 +134,7 @@
 def bin2long(data):
 	# thanks </F>!
 	v = 0
-	for i in map(ord, data):
+	for i in map(byteord, data):
 	    v = v<<8 | i
 	return v
 
diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
index 8ca10b0..118559b 100644
--- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py
+++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
@@ -217,7 +217,7 @@
 	index = 0
 	dataLen = len(data)
 	while index < dataLen:
-		length = ord(data[index])
+		length = byteord(data[index])
 		strings.append(data[index+1:index+1+length])
 		index = index + 1 + length
 	return strings
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 426a079..f42539e 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -137,7 +137,7 @@
 	def readUInt24(self):
 		pos = self.pos
 		newpos = pos + 3
-		value = (ord(self.data[pos]) << 16) | (ord(self.data[pos+1]) << 8) | ord(self.data[pos+2])
+		value = (byteord(self.data[pos]) << 16) | (byteord(self.data[pos+1]) << 8) | byteord(self.data[pos+2])
 		value, = struct.unpack(">H", self.data[pos:newpos])
 		self.pos = newpos
 		return value