Index: src/uk/me/parabola/imgfmt/app/srt/CodePosition.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/CodePosition.java	(revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/CodePosition.java	(working copy)
@@ -20,19 +20,19 @@
  * @author Steve Ratcliffe
  */
 public class CodePosition {
-	private char primary;
-	private byte secondary;
-	private byte tertiary;
+	private int primary;
+	private int secondary;
+	private int tertiary;
 
-	public char getPrimary() {
+	public int getPrimary() {
 		return primary;
 	}
 
-	public byte getSecondary() {
+	public int getSecondary() {
 		return secondary;
 	}
 
-	public byte getTertiary() {
+	public int getTertiary() {
 		return tertiary;
 	}
 
@@ -47,23 +47,25 @@
 		case Collator.PRIMARY:
 			return primary;
 		case Collator.SECONDARY:
-			return secondary & 0xff;
+			return secondary;
 		case Collator.TERTIARY:
-			return tertiary & 0xff;
+			return tertiary;
 		default:
 			return 0;
 		}
 	}
 
-	public void setPrimary(char primary) {
+	public void setPrimary(int primary) {
 		this.primary = primary;
 	}
 
-	public void setSecondary(byte secondary) {
+	public void setSecondary(int secondary) {
+//		assert secondary >= 0 && secondary <= 0xf: secondary;
 		this.secondary = secondary;
 	}
 
-	public void setTertiary(byte tertiary) {
+	public void setTertiary(int tertiary) {
+//		assert tertiary >= 0 && tertiary <= 0xf: tertiary;	    
 		this.tertiary = tertiary;
 	}
 }
Index: src/uk/me/parabola/imgfmt/app/srt/SRTFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SRTFile.java	(revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/SRTFile.java	(working copy)
@@ -106,16 +106,16 @@
 		int secondary = sort.getSecondary(i);
 		int tertiary = sort.getTertiary(i);
 		if (isMulti) {
-			assert primary <= 0xffff;
-			assert secondary <= 0xff;
-			assert tertiary <= 0xff;
+			assert primary <= 0xffff : primary;
+			assert secondary <= 0xff : secondary;
+			assert tertiary <= 0xff : tertiary;
 			writer.put2u(primary);
 			writer.put1u(secondary);
 			writer.put1u(tertiary);
 		} else {
-			assert primary <= 0xff;
-			assert secondary <= 0xf;
-			assert tertiary <= 0xf;
+			assert primary <= 0xff : primary;
+			assert secondary <= 0xf : secondary;
+			assert tertiary <= 0xf : tertiary;
 			writer.put1u(primary);
 			writer.put1u((tertiary << 4) | (secondary & 0xf));
 		}
Index: src/uk/me/parabola/imgfmt/app/srt/Sort.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/Sort.java	(revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/Sort.java	(working copy)
@@ -135,7 +135,7 @@
 			for (int i = 0; i < 256; i++) {
 				if (((p.flags[i] >>> 4) & 0xf) == 0) {
 					if (p.getPrimary(i) != 0) {
-						byte second = p.getSecondary(i);
+						int second = p.getSecondary(i);
 						maxSecondary = Math.max(maxSecondary, second);
 						if (second != 0) {
 							maxTertiary = Math.max(maxTertiary, p.getTertiary(i));
@@ -626,7 +626,7 @@
 		private final byte[] tertiary = new byte[256];
 		private final byte[] flags = new byte[256];
 
-		char getPrimary(int ch) {
+		int getPrimary(int ch) {
 			return primary[ch & 0xff];
 		}
 
@@ -634,19 +634,21 @@
 			primary[ch & 0xff] = (char) val;
 		}
 
-		byte getSecondary(int ch) {
-			return secondary[ch & 0xff];
+		int getSecondary(int ch) {
+			return secondary[ch & 0xff] & 0xff;
 		}
 
 		void setSecondary(int ch, int val) {
+//			assert val >= 0 && val <= 0xf: val;
 			secondary[ch & 0xff] = (byte) val;
 		}
 
-		byte getTertiary(int ch) {
-			return tertiary[ch & 0xff];
+		int getTertiary(int ch) {
+			return tertiary[ch & 0xff] & 0xff;
 		}
 
 		void setTertiary(int ch, int val) {
+//			assert val >= 0 && val <= 0xf: val;	    
 			tertiary[ch & 0xff] = (byte) val;
 		}
 
@@ -661,9 +663,9 @@
 			case Collator.PRIMARY:
 				return getPrimary(ch) & 0xffff;
 			case Collator.SECONDARY:
-				return getSecondary(ch) & 0xff;
+				return getSecondary(ch);
 			case Collator.TERTIARY:
-				return getTertiary(ch) & 0xff;
+				return getTertiary(ch);
 			default:
 				assert false : "bad collation type passed";
 				return 0;
Index: src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java	(revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java	(working copy)
@@ -173,20 +173,21 @@
 		int rec;
 		if (posLength == 2) {
 			rec = reader.get2u();
-			cp.setPrimary((char) (rec & 0xff));
-			cp.setSecondary((byte) ((rec >> 8) & 0xf));
-			cp.setTertiary((byte) ((rec >> 12) & 0xf));
+			cp.setPrimary(rec & 0xff);
+			cp.setSecondary((rec >> 8) & 0xf);
+			cp.setTertiary((rec >> 12) & 0xf);
 			
 		} else if (posLength == 3) {
+			// what is the extra byte for ???
 			rec = reader.get3u();
-			cp.setPrimary((char) (rec & 0xff));
-			cp.setSecondary((byte) ((rec >> 8) & 0xf));
-			cp.setTertiary((byte) ((rec >> 12) & 0xf));
+			cp.setPrimary(rec & 0xff);
+			cp.setSecondary((rec >> 8) & 0xf);
+			cp.setTertiary((rec >> 12) & 0xf);
 		} else if (posLength == 4) {
 			rec = reader.get4();
-			cp.setPrimary((char) (rec & 0xffff));
-			cp.setSecondary((byte) ((rec >> 16) & 0xff));
-			cp.setTertiary((byte) ((rec >> 24) & 0xff));
+			cp.setPrimary(rec & 0xffff);
+			cp.setSecondary((rec >> 16) & 0xff);
+			cp.setTertiary((rec >> 24) & 0xff);
 		} else {
 			throw new RuntimeException("unexpected value posLength " + posLength);
 		}
Index: src/uk/me/parabola/mkgmap/srt/SrtTextReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/srt/SrtTextReader.java	(revision 4285)
+++ src/uk/me/parabola/mkgmap/srt/SrtTextReader.java	(working copy)
@@ -329,7 +329,7 @@
 			CodePosition cp = new CodePosition();
 			int b = r.getBval();
 			int primary = sort.getPrimary(b);
-			cp.setPrimary((char) primary);
+			cp.setPrimary(primary);
 
 			// We do not want the character to sort fully equal to the expanded characters (or any other
 			// character so adjust the ordering at other strengths.  May need further tweaks.
@@ -346,15 +346,15 @@
 				} else {
 					secondary = 1;
 				}
-				cp.setSecondary((byte) (secondary));
-				cp.setTertiary((byte) (tertiary));
+				cp.setSecondary(secondary);
+				cp.setTertiary(tertiary);
 			} else {
 				num++;
-				secondary = sort.getSecondary(b) & 0xff;
-				cp.setSecondary((byte) (secondary + 7));
+				secondary = sort.getSecondary(b);
+				cp.setSecondary(secondary + 7);
 
-				tertiary = sort.getTertiary(b) & 0xff;
-				cp.setTertiary((byte) (tertiary + 2));
+				tertiary = sort.getTertiary(b);
+				cp.setTertiary(tertiary + 2);
 			}
 			expansions.add(cp);
 		}
