URL Encoding in Midlet

I am trying to write a midlet which, takes the input from the user on the phone and requests a response from server. For this I am using http connection. I was wondering if there is any method that I can use equivalent to URLencode in java.net package available in midp for URL encoding of the strings.

Thank you,

Kedar

[345 byte] By [kpanse] at [2007-9-26 9:15:03]
# 1
I have a similar problem and one solution is to add the source code of java.net.URLEncoder along with java.util.BitSet to your midlet application. It requires a little bit of rewriting to avoid having to add more than these two classes.
gabrielmcdermott at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
I have the same problem as well. If you have any sample code, I will be gratful if you can email to me.
kinwinglam at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

I copied the source of URLEncoder and BitSet from the standard java source. I deleted some functionality and removed the implementation of serializable so that I did not require any further classes. Hopefully the material below does the trick.

File for BitSet.java

package urlencode;

import java.io.*;

/*

* @author Arthur van Hoff

* @author Michael McCloskey

* @version 1.46, 02/02/00

* @sinceJDK1.0

*/

public class BitSet {

private final static int ADDRESS_BITS_PER_UNIT = 6;

private final static int BITS_PER_UNIT = 1 << ADDRESS_BITS_PER_UNIT;

private final static int BIT_INDEX_MASK = BITS_PER_UNIT - 1;

private long bits[]; // this should be called unit[]

private transient int unitsInUse = 0;

private static final long serialVersionUID = 7997698588986878753;

private static int unitIndex(int bitIndex) {

return bitIndex >> ADDRESS_BITS_PER_UNIT;

}

private static long bit(int bitIndex) {

return 1 << (bitIndex & BIT_INDEX_MASK);

}

private void recalculateUnitsInUse() {

int i;

for (i = unitsInUse-1; i >= 0; i--)

if(bits[i] != 0)

break; //this unit is in use!

unitsInUse = i+1; //the new logical size

}

public BitSet() {

this(BITS_PER_UNIT);

}

public BitSet(int nbits) {

if (nbits < 0)

throw new NegativeArraySizeException(Integer.toString(nbits));

bits = new long[(unitIndex(nbits-1) + 1)];

}

private void ensureCapacity(int unitsRequired) {

if (bits.length < unitsRequired) {

int request = Math.max(2 * bits.length, unitsRequired);

long newBits[] = new long[request];

System.arraycopy(bits, 0, newBits, 0, unitsInUse);

bits = newBits;

}

}

public int length() {

if (unitsInUse == 0)

return 0;

int highestBit = (unitsInUse - 1) * 64;

long highestUnit = bits[unitsInUse - 1];

do {

highestUnit = highestUnit >>> 1;

highestBit++;

} while(highestUnit > 0);

return highestBit;

}

public void set(int bitIndex) {

if (bitIndex < 0)

throw new IndexOutOfBoundsException(Integer.toString(bitIndex));

int unitIndex = unitIndex(bitIndex);

int unitsRequired = unitIndex+1;

if (unitsInUse < unitsRequired) {

ensureCapacity(unitsRequired);

bits[unitIndex] |= bit(bitIndex);

unitsInUse = unitsRequired;

} else {

bits[unitIndex] |= bit(bitIndex);

}

}

public void clear(int bitIndex) {

if (bitIndex < 0)

throw new IndexOutOfBoundsException(Integer.toString(bitIndex));

int unitIndex = unitIndex(bitIndex);

if (unitIndex >= unitsInUse)

return;

bits[unitIndex] &= ~bit(bitIndex);

if (bits[unitsInUse-1] == 0)

recalculateUnitsInUse();

}

public void andNot(BitSet set) {

int unitsInCommon = Math.min(unitsInUse, set.unitsInUse);

// perform logical (a & !b) on bits in common

for (int i=0; i<unitsInCommon; i++) {

bits[i] &= ~set.bits[i];

}

recalculateUnitsInUse();

}

public boolean get(int bitIndex) {

if (bitIndex >< 0)

throw new IndexOutOfBoundsException(Integer.toString(bitIndex));

boolean result = false;

int unitIndex = unitIndex(bitIndex);

if (unitIndex < unitsInUse)

result = ((bits[unitIndex] & bit(bitIndex)) != 0);

return result;

}

public void and(BitSet set) {

if (this == set)

return;

int oldUnitsInUse = unitsInUse;

unitsInUse = Math.min(unitsInUse, set.unitsInUse);

int i;

for(i=0; i<unitsInUse; i++)

bits[i] &= set.bits[i];

for( ; i >< oldUnitsInUse; i++)

bits[i] = 0;

if (unitsInUse > 0 && bits[unitsInUse - 1] == 0)

recalculateUnitsInUse();

}

public void or(BitSet set) {

if (this == set)

return;

ensureCapacity(set.unitsInUse);

int unitsInCommon = Math.min(unitsInUse, set.unitsInUse);

int i;

for(i=0; i<unitsInCommon; i++)

bits[i] |= set.bits[i];

for(; i><set.unitsInUse; i++)

bits[i] = set.bits[i];

if (unitsInUse >< set.unitsInUse)

unitsInUse = set.unitsInUse;

}

public void xor(BitSet set) {

int unitsInCommon;

if (unitsInUse >= set.unitsInUse) {

unitsInCommon = set.unitsInUse;

} else {

unitsInCommon = unitsInUse;

int newUnitsInUse = set.unitsInUse;

ensureCapacity(newUnitsInUse);

unitsInUse = newUnitsInUse;

}

int i;

for (i=0; i<unitsInCommon; i++)

bits[i] ^= set.bits[i];

for ( ; i><set.unitsInUse; i++)

bits[i] = set.bits[i];

recalculateUnitsInUse();

}

public int hashCode() {

long h = 1234;

for (int i = bits.length; --i >= 0; )

h ^= bits[i] * (i + 1);

return (int)((h >> 32) ^ h);

}

public int size() {

return bits.length << ADDRESS_BITS_PER_UNIT;

}

public boolean equals(Object obj) {

if (!(obj instanceof BitSet))

return false;

if (this == obj)

return true;

BitSet set = (BitSet) obj;

int minUnitsInUse = Math.min(unitsInUse, set.unitsInUse);

for (int i = 0; i < minUnitsInUse; i++)

if (bits[i] != set.bits[i])

return false;

if (unitsInUse > minUnitsInUse) {

for (int i = minUnitsInUse; i<unitsInUse; i++)

if (bits[i] != 0)

return false;

} else {

for (int i = minUnitsInUse; i><set.unitsInUse; i++)

if (set.bits[i] != 0)

return false;

}

return true;

}

public String toString() {

int numBits = unitsInUse ><< ADDRESS_BITS_PER_UNIT;

StringBuffer buffer = new StringBuffer(8*numBits + 2);

String separator = "";

buffer.append('{');

for (int i = 0 ; i < numBits; i++) {

if (get(i)) {

buffer.append(separator);

separator = ", ";

buffer.append(i);

}

}

buffer.append('}');

return buffer.toString();

}

}

The code for URLEncoder is

package urlencode;

import java.io.ByteArrayOutputStream;

import java.io.OutputStreamWriter;

import java.io.IOException;

/**

* @author Herb Jellinek

* @version 1.18, 02/02/00

* @sinceJDK1.0

*/

public class URLEncoder {

static BitSet dontNeedEncoding;

static final int caseDiff = ('a' - 'A');

static {

dontNeedEncoding = new BitSet(256);

int i;

for (i = 'a'; i <= 'z'; i++) {

dontNeedEncoding.set(i);

}

for (i = 'A'; i <= 'Z'; i++) {

dontNeedEncoding.set(i);

}

for (i = '0'; i <= '9'; i++) {

dontNeedEncoding.set(i);

}

dontNeedEncoding.set(' '); /* encoding a space to a + is done in the encode() method */

dontNeedEncoding.set('-');

dontNeedEncoding.set('_');

dontNeedEncoding.set('.');

dontNeedEncoding.set('*');

}

private URLEncoder() { }

public static String encode(String s) {

int maxBytesPerChar = 10;

StringBuffer out = new StringBuffer(s.length());

ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);

OutputStreamWriter writer = new OutputStreamWriter(buf);

for (int i = 0; i < s.length(); i++) {

int c = (int)s.charAt(i);

if (dontNeedEncoding.get(c)) {

if (c == ' ') {

c = '+';

}

out.append((char)c);

} else {

// convert to external encoding before hex conversion

try {

writer.write(c);

writer.flush();

} catch(IOException e) {

buf.reset();

continue;

}

byte[] ba = buf.toByteArray();

for (int j = 0; j < ba.length; j++) {

out.append('%');

char ch = forDigit((ba[j] >> 4) & 0xF, 16);

// converting to use uppercase letter as part of

// the hex value if ch is a letter.

if (isLetter(ch)) {

ch -= caseDiff;

}

out.append(ch);

ch = forDigit(ba[j] & 0xF, 16);

if (isLetter(ch)) {

ch -= caseDiff;

}

out.append(ch);

}

buf.reset();

}

}

return out.toString();

}

public static char forDigit(int digit, int radix) {

if ((digit >= radix) || (digit < 0)) {

return '\0';

}

if ((radix < MIN_RADIX) || (radix > MAX_RADIX)) {

return '\0';

}

if (digit < 10) {

return (char)('0' + digit);

}

return (char)('a' - 10 + digit);

}

public static boolean isLetter(char ch) {

return (((((1 << UPPERCASE_LETTER) |

(1 << LOWERCASE_LETTER) |

(1 << TITLECASE_LETTER) |

(1 << MODIFIER_LETTER) |

(1 << OTHER_LETTER))

>> (A[Y[(X[ch>>6]<<5)|((ch>>1)&0x1F)]|(ch&0x1)] & 0x1F)) & 1) != 0);

}

public static final int MIN_RADIX = 2;

public static final int MAX_RADIX = 36;

public static final byte

UPPERCASE_LETTER= 1,

LOWERCASE_LETTER= 2,

TITLECASE_LETTER= 3,

MODIFIER_LETTER= 4,

OTHER_LETTER= 5;

private static final byte X[] = new byte[1024];

private static final String X_DATA =

"\u0100\u0302\u0504\u0706\u0908\u0B0A\u0D0C\u0F0E\u1110\u1312\u1514\u1716\u1918"+

"\u1B1A\u1C1C\u1C1C\u1C1C\u1C1C\u1E1D\u201F\u2221\u2423\u2625\u2827\u2A29\u2C2B"+

"\u2E2D\u1C1C\u302F\u3231\u3433\u1C35\u1C1C\u3736\u3938\u3B3A\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u3C3C\u3E3D\u403F\u4241\u4443"+

"\u4645\u4847\u4A49\u4C4B\u4E4D\u504F\u1C1C\u5251\u5453\u5555\u5756\u5758\u1C1C"+

"\u5A59\u1C5B\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u5D5C\u5F5E\u3860\u1C61\u6362\u6564\u6766\u6866"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u1C69\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C"+

"\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u1C1C\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838\u3838"+

"\u3838\u3838\u1C6A\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B"+

"\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6B6B\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C"+

"\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C"+

"\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C"+

"\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C\u6C6C"+

"\u6C6C\u6C6C\u6C6C\u6C6C\u3838\u3838\u1C6D\u1C1C\u6F6E\u7170\u7272\u7272\u7473"+

"\u7675\u7877\u7972\u7B7A\u7D7C";

// The Y table has 4032 entries for a total of 8064 bytes.

private static final short Y[] = new short[4032];

private static final String Y_DATA =

"\000\000\000\000\002\004\004\000\000\000\000\000\000\000\004\004\006\010\012"+

"\014\016\020\022\024\026\026\026\026\026\030\032\034\036\040\040\040\040\040"+

"\040\040\040\040\040\040\040\042\044\046\050\052\052\052\052\052\052\052\052"+

"\052\052\052\052\054\056\060\000\000\000\000\000\000\000\000\000\000\000\000"+

"\000\000\000\000\062\064\064\066\070\072\074\076\100\102\104\106\110\112\114"+

"\116\120\120\120\120\120\120\120\120\120\120\120\122\120\120\120\124\126\126"+

"\126\126\126\126\126\126\126\126\126\130\126\126\126\132\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\136\134\134\134\140\142\142\142\142\142\142\142\144\134\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\146\142"+

"\142\150\152\134\134\154\156\160\144\162\164\156\166\170\134\172\174\176\134"+

"\134\134\200\202\204\134\206\210\212\142\214\134\216\134\220\220\220\222\224"+

"\226\222\230\142\142\142\142\142\142\142\232\134\134\134\134\134\134\134\134"+

"\134\234\226\134\236\236\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\236\172\240\242\244\246\250\172\172"+

"\252\254\172\172\256\172\172\260\172\262\264\172\172\172\172\172\172\266\172"+

"\172\270\272\172\172\172\274\172\172\172\172\172\172\172\172\172\172\276\236"+

"\236\236\300\300\300\300\302\304\300\300\300\306\306\306\306\306\306\306\300"+

"\306\306\306\306\306\306\310\300\300\302\306\306\236\236\236\236\236\236\236"+

"\236\236\236\236\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312"+

"\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312\312"+

"\312\236\236\236\236\236\236\236\236\236\236\236\236\236\312\236\236\236\236"+

"\236\236\236\236\236\314\236\236\316\236\320\236\236\306\322\324\326\330\332"+

"\334\120\120\120\120\120\120\120\120\336\120\120\120\120\340\342\344\126\126"+

"\126\126\126\126\126\126\346\126\126\126\126\350\352\354\356\360\362\236\364"+

"\364\364\364\134\134\134\134\134\134\134\366\216\236\236\236\236\236\236\370"+

"\372\372\372\372\372\374\372\120\120\120\120\120\120\120\120\120\120\120\120"+

"\120\120\120\120\126\126\126\126\126\126\126\126\126\126\126\126\126\126\126"+

"\126\376\u0100\u0100\u0100\u0100\u0100\u0102\u0100\134\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\u0104\312\u0106\236\236\236\236"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\134\134\134\u0108\142\u010A\u010C\u010A\u010C\u010A\236\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\236\134\134\134\134\236\134\236"+

"\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\u010E\u0110\u0110\u0110\u0110\u0110\u0110\u0110"+

"\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0112\u0114"+

"\314\314\314\u0116\u0118\u0118\u0118\u0118\u0118\u0118\u0118\u0118\u0118\u0118"+

"\u0118\u0118\u0118\u0118\u0118\u0118\u0118\u0118\u011A\u011C\236\236\236\u011E"+

"\u0120\u0120\u0120\u0120\u0120\u0120\u0120\u0120\u011E\u0120\u0120\u0120\u0120"+

"\u0120\u0120\u0120\u0120\u0120\u0120\u0120\u011E\u0120\u0122\u0122\u0124\u0126"+

"\236\236\236\236\236\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u012A\236\236\u0128\u012C\u012E\236\236\236\236\236"+

"\236\236\236\236\236\236\u012E\236\236\236\236\236\236\u0130\236\u0130\u0132"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u012A"+

"\236\236\u0134\u0128\u0128\u0128\u0128\u0136\u0120\u0120\u0120\u0126\236\236"+

"\236\236\236\236\u0138\u0138\u0138\u0138\u0138\u013A\u013C\236\u013E\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\236\u0128\u0128\u012A\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u012A\u0128\u0128\u0140\u0120\u0120\u0120"+

"\u0142\u0144\u0120\u0120\u0146\u0148\u014A\u0120\u0120\236\026\026\026\026"+

"\026\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\u014C"+

"\u014E\u0150\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\236\u0152\u0154\u0156\312\312\312"+

"\u014E\u0154\u0156\236\u0104\312\u0106\236\220\220\220\220\220\312\314\u0158"+

"\u0158\u0158\u0158\u0158\320\236\236\236\236\236\236\236\u014C\u0154\u0150"+

"\220\220\220\u015A\u0150\u015A\u0150\220\220\220\220\220\220\220\220\220\220"+

"\u015A\220\220\220\u015A\u015A\236\220\220\236\u0106\u0154\u0156\312\u0106"+

"\u015C\u015E\u015C\u0156\236\236\236\236\u015C\236\236\220\u0150\220\312\236"+

"\u0158\u0158\u0158\u0158\u0158\220\u0160\u0162\u0162\u0164\u0166\236\236\236"+

"\u0106\u0150\220\220\u015A\236\u0150\u015A\u0150\220\220\220\220\220\220\220"+

"\220\220\220\u015A\220\220\220\u015A\220\u0150\u015A\220\236\u0106\u0154\u0156"+

"\u0106\236\u014C\u0106\u014C\312\236\236\236\236\236\u0150\220\u015A\u015A"+

"\236\236\236\u0158\u0158\u0158\u0158\u0158\312\220\u015A\236\236\236\236\236"+

"\u014C\u014E\u0150\220\220\220\u0150\u0150\220\u0150\220\220\220\220\220\220"+

"\220\220\220\220\u015A\220\220\220\u015A\220\u0150\220\220\236\u0152\u0154"+

"\u0156\312\312\u014C\u014E\u015C\u0156\236\u0166\236\236\236\236\236\236\236"+

"\u015A\236\236\u0158\u0158\u0158\u0158\u0158\236\236\236\236\236\236\236\236"+

"\u014C\u0154\u0150\220\220\220\u015A\u0150\u015A\u0150\220\220\220\220\220"+

"\220\220\220\220\220\u015A\220\220\220\u015A\220\236\220\220\236\u0152\u0156"+

"\u0156\312\236\u015C\u015E\u015C\u0156\236\236\236\236\u014E\236\236\220\u0150"+

"\220\236\236\u0158\u0158\u0158\u0158\u0158\u0166\236\236\236\236\236\236\236"+

"\236\u014E\u0150\220\220\u015A\236\220\u015A\220\220\236\u0150\u015A\u015A"+

"\220\236\u0150\u015A\236\220\u015A\236\220\220\220\220\u0150\220\236\236\u0154"+

"\u014E\u015E\236\u0154\u015E\u0154\u0156\236\236\236\236\u015C\236\236\236"+

"\236\236\236\236\u0168\u0158\u0158\u0158\u0158\u016A\u016C\236\236\236\236"+

"\236\236\u015C\u0154\u0150\220\220\220\u015A\220\u015A\220\220\220\220\220"+

"\220\220\220\220\220\220\u015A\220\220\220\220\220\u0150\220\220\236\236\312"+

"\u014E\u0154\u015E\312\u0106\312\312\236\236\236\u014C\u0106\236\236\236\236"+

"\220\236\236\u0158\u0158\u0158\u0158\u0158\236\236\236\236\236\236\236\236"+

"\236\u0154\u0150\220\220\220\u015A\220\u015A\220\220\220\220\220\220\220\220"+

"\220\220\220\u015A\220\220\220\220\220\u0150\220\220\236\236\u0156\u0154\u0154"+

"\u015E\u014E\u015E\u0154\312\236\236\236\u015C\u015E\236\236\236\u015A\220"+

"\236\236\u0158\u0158\u0158\u0158\u0158\236\236\236\236\236\236\236\236\236"+

"\u0154\u0150\220\220\220\u015A\220\u015A\220\220\220\220\220\220\220\220\220"+

"\220\220\u015A\220\220\220\220\220\220\220\220\236\236\u0154\u0156\312\236"+

"\u0154\u015E\u0154\u0156\236\236\236\236\u015C\236\236\236\236\220\236\236"+

"\u0158\u0158\u0158\u0158\u0158\236\236\236\236\236\236\236\236\u0150\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\u016E\u0170\220\312\312\312\u0106\236\u0172\220\220\220\u0174\312\312"+

"\312\u0176\u0178\u0178\u0178\u0178\u0178\314\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\u0150\u015A\u015A\u0150\u015A\u015A"+

"\u0150\236\236\236\220\220\u0150\220\220\220\u0150\220\u0150\u0150\236\220"+

"\u0150\u016E\u0170\220\312\312\312\u014C\u0152\236\220\220\u015A\316\312\312"+

"\312\236\u0178\u0178\u0178\u0178\u0178\236\220\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\u017A\u017A\314\314\314\314\314\314"+

"\314\u017C\u017A\u017A\312\u017A\u017A\u017A\u017E\u017E\u017E\u017E\u017E"+

"\u0180\u0180\u0180\u0180\u0180\u0104\u0104\u0104\u0182\u0182\u0154\220\220"+

"\220\220\u0150\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\236\236\236\u014C\312\312\312\312\312\312\u014E\312\312\u0184\312\312"+

"\312\236\236\312\312\312\u014C\u014C\312\312\312\312\312\312\312\312\312\312"+

"\236\u014C\312\312\312\u014C\236\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110"+

"\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\u0110\236\236"+

"\236\236\236\172\172\172\172\172\172\172\172\172\172\172\172\172\172\172\172"+

"\172\172\172\276\236\u011C\236\236\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\236\236\u0150"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\u015A\236\236\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\236\236\236\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\172\172\u0186\236\236\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134\134"+

"\134\134\134\134\236\236\236\u0188\u0188\u0188\u0188\u018A\u018A\u018A\u018A"+

"\u0188\u0188\u0188\236\u018A\u018A\u018A\236\u0188\u0188\u0188\u0188\u018A"+

"\u018A\u018A\u018A\u0188\u0188\u0188\u0188\u018A\u018A\u018A\u018A\u0188\u0188"+

"\u0188\236\u018A\u018A\u018A\236\u018C\u018C\u018C\u018C\u018E\u018E\u018E"+

"\u018E\u0188\u0188\u0188\u0188\u018A\u018A\u018A\u018A\u0190\u0192\u0192\u0194"+

"\u0196\u0198\u019A\236\u0188\u0188\u0188\u0188\u018A\u018A\u018A\u018A\u0188"+

"\u0188\u0188\u0188\u018A\u018A\u018A\u018A\u0188\u0188\u0188\u0188\u018A\u018A"+

"\u018A\u018A\u0188\u019C\276\172\u018A\u019E\u01A0\u01A2\306\u019C\276\172"+

"\u01A4\u01A4\u01A0\306\u0188\172\236\172\u018A\u01A6\u01A8\306\u0188\172\u01AA"+

"\172\u018A\u01AC\u01AE\306\236\u019C\276\172\u01B0\u01B2\u01A0\310\u01B4\u01B4"+

"\u01B4\u01B6\u01B4\u01B4\u01B8\u01BA\u01BC\u01BC\u01BC\014\u01BE\u01C0\u01BE"+

"\u01C0\014\014\014\014\u01C2\u01B8\u01B8\u01C4\u01C6\u01C6\u01C8\014\u01CA"+

"\u01CC\014\u01CE\u01D0\014\u01D2\u01D4\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\u01B8\u01B8\u01B8\u01D6\236\102\102\102\u01D8"+

"\u01D2\u01DA\u01DC\u01DC\u01DC\u01DC\u01DC\u01D8\u01D2\u01D4\236\236\236\236"+

"\236\236\236\236\064\064\064\064\064\064\u01DE\236\236\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\312\312\312\312\312\312\u01E0\u01E2"+

"\u01E4\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\066\u01E6"+

"\066\u01E8\066\u01EA\u01EC\u01EE\u01EC\u01F0\u01E8\066\u01EC\u01EC\u01EC\066"+

"\066\066\u01E6\u01E6\u01E6\u01EC\u01EC\u01EE\u01EC\u01E8\u01F2\u01F4\u01F6"+

"\236\236\236\236\236\236\236\236\236\236\236\236\u01F8\114\114\114\114\114"+

"\u01FA\u01FC\u01FC\u01FC\u01FC\u01FC\u01FC\u01FE\u01FE\u0200\u0200\u0200\u0200"+

"\u0200\u0200\u0202\u0202\u0204\u0206\236\236\236\236\236\236\u0208\u0208\u020A"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\u020A\u020A\066\066\066\066\066"+

"\066\066\066\066\066\u020C\236\236\236\236\236\236\236\236\236\236\u020E\u0210"+

"\032\u0208\u0210\u0210\u0210\u0208\u020E\u01D8\u020E\032\u0208\u0210\u0210"+

"\u020E\u0210\032\032\032\u0208\u020E\u0210\u0210\u0210\u0210\u0208\u0208\u020E"+

"\u020E\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\032\u0208\u0208\u0210"+

"\u0210\u0208\u0208\u0208\u0208\u020E\032\032\u0210\u0210\u0210\u0210\u0208"+

"\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210"+

"\u0210\u0210\032\u020E\u0210\032\u0208\u0208\032\u0208\u0208\u0208\u0208\u0210"+

"\u0208\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\032\u0208\u0208"+

"\u0210\u0208\u0208\u0208\u0208\u020E\u0210\u0210\u0208\u0210\u0208\u0208\u0210"+

"\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0210\u0208\u0210"+

"\236\236\236\236\236\236\236\u020C\066\066\066\u0210\u0210\066\066\066\066"+

"\066\066\066\066\066\066\u0210\066\066\066\u0212\u0214\066\066\066\066\066"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u0166\236\236\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\u020C\236\236"+

"\236\236\236\236\236\236\236\236\236\236\236\066\066\066\066\066\u020C\236"+

"\236\236\236\236\236\236\236\236\236\u0216\u0216\u0216\u0216\u0216\u0216\u0216"+

"\u0216\u0216\u0216\u0218\u0218\u0218\u0218\u0218\u0218\u0218\u0218\u0218\u0218"+

"\u021A\u021A\u021A\u021A\u021A\u021A\u021A\u021A\u021A\u021A\066\066\066\066"+

"\066\066\066\066\066\066\066\066\066\u021C\u021C\u021C\u021C\u021C\u021C\u021C"+

"\u021C\u021C\u021C\u021C\u021C\u021C\u021E\u021E\u021E\u021E\u021E\u021E\u021E"+

"\u021E\u021E\u021E\u021E\u021E\u021E\u0220\236\236\236\236\236\236\236\236"+

"\236\236\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\066\066\066\066\066\066\066\236\236\236\236\236\066\066\066\066\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\236\236\236\236\236"+

"\236\236\236\066\066\066\066\066\066\066\066\066\066\236\236\236\066\066\066"+

"\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\u0222\066"+

"\u020C\066\066\236\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\u0222\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066\066"+

"\u0222\u0222\066\u020C\236\u020C\066\066\066\u020C\u0222\066\066\066\236\236"+

"\236\236\236\236\236\u0224\u0224\u0224\u0224\u0224\u0216\u0216\u0216\u0216"+

"\u0216\u0226\u0226\u0226\u0226\u0226\u020C\236\066\066\066\066\066\066\066"+

"\066\066\066\066\066\u0222\066\066\066\066\066\066\u020C\006\014\u0228\u022A"+

"\016\016\016\016\016\066\016\016\016\016\u022C\u022E\u0230\u0232\u0232\u0232"+

"\u0232\312\312\312\u0234\u0236\u0236\066\236\236\236\u0222\u0150\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\u015A\236\u014C\u0238\300\316\u0150\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\u016E\300\316"+

"\236\236\u0150\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\u015A\236\u0150\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\u015A\u017A\u0180\u0180\u017A\u017A\u017A\u017A\u017A\236\236"+

"\236\236\236\236\236\236\236\236\236\236\236\236\236\236\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u0166\236"+

"\u0180\u0180\u0180\u0180\u0180\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\236\u023A\u023C\u023C\u023C\u023C\u023C\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u0166\236\236\236\236\236\236\236\u017A\u017A\u017A\u017A"+

"\u017A\u017A\236\236\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u0166\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u0166\236\u023A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\236\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A\u017A"+

"\u017A\u017A\u017A\u017A\u017A\u017A\u0166\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\236\236\236\236\236\236\236\236"+

"\236\236\236\236\236\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\236\236\236\236\236\236\236\236\236\236\236\236\236\236\u023E"+

"\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E"+

"\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E\u023E"+

"\u023E\u023E\u023E\u023E\u023E\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240"+

"\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240"+

"\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\u0240\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\236\236\236\236\236\236\236\236\236\172\172\172\276\236\236\236\236"+

"\236\u0242\172\172\236\236\236\u013E\u0128\u0128\u0128\u0128\u0244\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u012A\u0128\u0128\u012A\u012A\u0128\u0132\u012A\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\u0132"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u01BE\236\236\236\236\236\236\236"+

"\236\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\236\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\236\236\236\236\236"+

"\236\236\236\236\236\236\236\236\236\236\236\236\236\236\236\u0128\u0128\u0128"+

"\u0128\u0128\u0128\236\236\236\236\236\236\236\236\236\236\236\236\236\236"+

"\236\236\236\236\u0246\u0246\236\236\236\236\236\236\u0248\u024A\u024C\u024E"+

"\u024E\u024E\u024E\u024E\u024E\u024E\u0250\236\u0252\014\u01CE\u0254\014\u0256"+

"\014\014\u022C\u024E\u024E\u01CC\014\074\u0208\u0258\u025A\014\236\236\u0128"+

"\u012A\u012A\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128"+

"\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u0128\u012A\u025C"+

"\u0252\014\u025E\014\u01BE\u0260\u0248\014\026\026\026\026\026\014\u0208\u0262"+

"\036\040\040\040\040\040\040\040\040\040\040\040\040\u0264\u0266\046\050\052"+

"\052\052\052\052\052\052\052\052\052\052\052\u0268\u026A\u0258\u0252\u01BE"+

"\u026C\220\220\220\220\220\u026E\220\220\220\220\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\220\220\220\300\220\220\220\220\220\220\220"+

"\220\220\220\220\220\220\220\220\u015A\236\220\220\220\236\220\220\220\236"+

"\220\220\220\236\220\u015A\236\u0270\u0272\u0274\u0276\u0208\u0208\u020A\u020C"+

"\236\236\236\236\236\236\066\236";

// The A table has 632 entries for a total of 2528 bytes.

private static final int A[] = new int[632];

private static final String A_DATA =

"\001\u018F\001\u018F\001\u018F\004\u012F\004\u018F\004\u018F\004\u014C\000"+

"\u0198\000\u0198\000\270\006\272\000\270\000\u0198\000\u0198\000\u0175\000"+

"\u0176\000\u0198\000\271\000\370\000\264\000\370\000\230\003\u6069\003\u6069"+

"\000\370\000\u0198\000\u0179\000\u0199\000\u0179\000\u0198\000\u0198\u0827"+

"\uFE21\u0827\uFE21\u0827\uFE21\u0827\uFE21\000\u0175\000\u0198\000\u0176\000"+

"\u019B\005\u0197\000\u019B\u0817\uFE22\u0817\uFE22\u0817\uFE22\u0817\uFE22"+

"\000\u0175\000\u0199\000\u0176\000\u0199\001\u018F\000\u014C\000\u0198\006"+

"\272\006\272\000\u019C\000\u019C\000\u019B\000\u019C\007\u0182\000\u0195\000"+

"\u0199\000\u0194\000\u019C\000\u019B\000\274\000\271\000\u606B\000\u606B\000"+

"\u019B\007\u0182\000\u019C\000\u0198\000\u019B\000\u506B\007\u0182\000\u0196"+

"\000\u818B\000\u818B\000\u818B\000\u0198\u0827\041\u0827\041\u0827\041\000"+

"\u0199\u0827\041\007\042\u0817\042\u0817\042\u0817\042\000\u0199\u0817\042"+

"\uE1D7\042\147\041\127\042\uCE67\041\u3A17\042\007\042\147\041\127\042\147"+

"\041\127\042\007\042\uE1E7\041\147\041\127\042\u4B17\042\007\042\u34A7\041"+

"\u33A7\041\147\041\127\042\u3367\041\u3367\041\147\041\u13E7\041\u32A7\041"+

"\u32E7\041\147\041\u33E7\041\007\042\u34E7\041\u3467\041\007\042\007\042\u34E7"+

"\041\u3567\041\007\042\u35A7\041\007\041\147\041\127\042\u36A7\041\007\045"+

"\007\042\u36A7\041\147\041\127\042\u3667\041\u3667\041\147\041\127\042\u36E7"+

"\041\007\042\007\045\007\045\007\045\257\041\177\043\237\042\257\041\177\043"+

"\237\042\237\042\147\041\127\042\u13D7\042\007\042\257\041\000\000\000\000"+

"\007\042\u3497\042\u3397\042\007\042\u3357\042\u3357\042\007\042\u3297\042"+

"\007\042\u32D7\042\u3357\042\007\042\007\042\u33D7\042\u3457\042\u34D7\042"+

"\007\042\u34D7\042\u3557\042\007\042\007\042\uCAA7\042\007\042\u3697\042\u3697"+

"\042\007\042\u3657\042\u3657\042\u36D7\042\007\042\007\042\000\000\007\044"+

"\007\044\007\044\000\073\000\073\007\044\000\073\000\073\000\073\000\000\003"+

"\046\003\046\000\070\000\070\007\044\000\000\000\070\000\000\u09A7\041\000"+

"\070\u0967\041\u0967\041\u0967\041\000\000\u1027\041\000\000\u0FE7\041\u0FE7"+

"\041\007\042\u0827\041\000\000\u0827\041\u0997\042\u0957\042\u0957\042\u0957"+

"\042\007\042\u0817\042\u07D7\042\u0817\042\u1017\042\u0FD7\042\u0FD7\042\000"+

"\000\u0F97\042\u0E57\042\007\041\007\041\007\041\u0BD7\042\u0D97\042\000\000"+

"\007\041\000\000\u1597\042\u1417\042\000\000\u1427\041\u1427\041\u1427\041"+

"\u1427\041\000\000\000\000\u1417\042\u1417\042\u1417\042\u1417\042\000\000"+

"\000\074\003\046\003\046\000\000\007\045\147\041\127\042\000\000\000\000\147"+

"\041\000\000\u0C27\041\u0C27\041\u0C27\041\u0C27\041\000\000\000\000\007\044"+

"\000\000\u0C17\042\u0C17\042\u0C17\042\u0C17\042\007\042\000\000\000\070\000"+

"\000\003\106\003\106\003\106\000\130\003\106\003\106\000\130\003\106\000\000"+

"\007\105\007\105\007\105\000\000\007\105\000\130\000\130\000\000\000\000\000"+

"\130\000\000\007\105\007\104\007\105\007\105\003\106\003\u40C9\003\u40C9\000"+

"\270\000\330\000\330\000\130\003\106\007\105\000\130\007\105\003\106\000\107"+

"\000\107\003\106\003\106\007\104\007\104\003\106\003\106\000\134\000\000\003"+

"\046\003\046\003\050\000\000\007\045\003\046\007\045\003\050\003\050\003\050"+

"\003\046\003\u7429\003\u7429\007\045\000\000\000\000\003\050\003\050\000\000"+

"\006\072\006\072\000\u5A2B\000\u5A2B\000\u802B\000\u6E2B\000\074\000\000\000"+

"\000\003\u7429\000\u742B\000\u802B\000\u802B\000\000\007\045\000\070\007\045"+

"\003\046\000\000\006\072\007\044\003\046\003\046\000\074\003\u6029\003\u6029"+

"\000\074\000\074\000\070\000\074\003\u4029\003\u4029\000\053\000\053\000\065"+

"\000\066\003\046\000\070\007\042\u0ED7\042\uFE17\042\uFE17\042\uFE27\041\uFE27"+

"\041\007\042\uFE17\042\000\000\uFE27\041\uED97\042\uED97\042\uEA97\042\uEA97"+

"\042\uE717\042\uE717\042\uE017\042\uE017\042\uE417\042\uE417\042\uE097\042"+

"\uE097\042\007\042\uFDD7\042\uEDA7\041\uEDA7\041\uFDE7\041\000\073\007\041"+

"\000\073\uEAA7\041\uEAA7\041\uE727\041\uE727\041\000\000\000\073\007\042\uFE57"+

"\042\uE427\041\uE427\041\uFE67\041\000\073\uE027\041\uE027\041\uE0A7\041\uE0A7"+

"\041\004\u014C\004\u014C\004\u014C\004\354\001\u0190\001\u0190\001\060\001"+

"\120\000\u0194\000\u0194\000\u0195\000\u0196\000\u0195\000\u0195\004\u010D"+

"\004\u010E\001\u0190\000\000\000\270\000\270\000\270\000\u0198\000\u0198\000"+

"\u0195\000\u0196\000\u0198\000\u0198\005\u0197\005\u0197\000\u0198\000\u0199"+

"\000\u0175\000\u0176\000\000\000\u606B\000\000\000\271\000\271\000\u0176\007"+

"\u0182\000\u406B\000\u406B\006\272\000\000\003\046\000\047\000\047\000\047"+

"\000\047\003\046\007\u0181\000\u019C\000\u019C\007\u0181\007\u0182\007\u0181"+

"\007\u0181\007\u0181\007\u0182\007\u0182\007\u0181\007\u0182\007\u0182\007"+

"\u0185\007\u0185\007\u0185\007\u0185\000\000\000\000\000\u818B\000\u818B\000"+

"\u458B\u0427\u422A\u0427\u422A\u0427\u802A\u0427\u802A\u0417\u622A\u0417\u622A"+

"\u0417\u802A\u0417\u802A\007\u802A\007\u802A\007\u802A\000\000\000\u0199\000"+

"\u0199\000\u0199\000\u019C\000\u019C\000\000\000\u0199\000\u0179\000\u0179"+

"\000\u0179\000\u019C\000\u0175\000\u0176\000\u019C\000\u438B\000\u438B\000"+

"\u5B8B\000\u5B8B\000\u738B\000\u738B\u06A0\u019C\u06A0\u019C\u0690\u019C\u0690"+

"\u019C\000\u6D8B\000\000\000\000\000\u019C\000\u578B\000\u578B\000\u6F8B\000"+

"\u6F8B\000\u019C\007\u0184\000\u0198\007\u738A\000\u0194\000\u0195\000\u0196"+

"\000\u0196\000\u019C\007\u402A\007\u402A\007\u402A\000\u0194\007\u0184\007"+

"\u0184\007\u0184\003\046\007\044\000\000\000\074\000\u422B\000\u422B\000\063"+

"\000\063\000\062\000\062\000\000\007\042\007\105\000\131\003\u0186\003\u0186"+

"\000\u0198\000\u0194\000\u0194\005\u0197\005\u0197\000\u0195\000\u0196\000"+

"\u0195\000\u0196\000\000\000\000\000\u0198\005\u0197\005\u0197\000\u0198\000"+

"\000\000\u0199\000\000\000\u0198\006\u019A\000\000\001\u0190\006\u019A\000"+

"\u0198\000\u0198\000\u0199\000\u0199\000\u0198\u0827\uFE21\000\u0195\000\u0198"+

"\000\u0196\u0817\uFE22\000\u0195\000\u0199\000\u0196\000\u0198\000\070\007"+

"\044\007\045\006\u019A\006\u019A\000\u0199\000\u019B\000\u019C\006\u019A\006"+

"\u019A\000\000";

// In all, the character property tables require 11616 bytes.

static {

{ // THIS CODE WAS AUTOMATICALLY CREATED BY GenerateCharacter:

int len = X_DATA.length();

int j=0;

for (int i=0; i<len; ++i) {

int c = X_DATA.charAt(i);

for (int k=0; k><2; ++k) {

X[j++] = (byte)c;

c >>= 8;

}

}

if (j != 1024) throw new RuntimeException();

}

{ // THIS CODE WAS AUTOMATICALLY CREATED BY GenerateCharacter:

if (Y_DATA.length() != 4032) throw new RuntimeException();

for (int i=0; i<4032; ++i)

Y[i] = (short)Y_DATA.charAt(i);

}

{ // THIS CODE WAS AUTOMATICALLY CREATED BY GenerateCharacter:

int len = A_DATA.length();

int j=0;

int charsInEntry=0;

int entry=0;

for (int i=0; i<len; ++i) {

entry |= A_DATA.charAt(i);

if (++charsInEntry == 2) {

A[j++] = entry;

entry = 0;

charsInEntry = 0;

}

else {

entry ><<= 16;

}

}

if (j != 632) throw new RuntimeException();

}

}

}

gabrielmcdermott at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

Try This .... (much smaller, and more midlet friendly...

public void URLEncode(String arg0, StringBuffer out) throws IOException {

ByteArrayOutputStream bOut = new ByteArrayOutputStream();

DataOutputStream dOut = new DataOutputStream(bOut);

dOut.writeUTF(arg0);

ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());

bIn.read();

bIn.read();

int c = bIn.read();

while (c >= 0) {

if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '*' || c == '_')

out.append((char) c);

else if (c == ' ')

out.append('+');

else {

if (c < 128) {

appendHex(c,out);

} else if (c < 224) {

appendHex(c,out);

appendHex(bIn.read(),out);

} else if (c < 240) {

appendHex(c,out);

appendHex(bIn.read(),out);

appendHex(bIn.read(),out);

}

}

c = bIn.read();

}

}

private void appendHex(int arg0, StringBuffer buff){

buff.append('%');

if (arg0<16) buff.append('0');

buff.append(Integer.toHexString(arg0));

}

tonywestonuk at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
Hi,Did you see when the message was posted. It is almost 3 years back.
prabhu_cbe at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6

Yes, I did notice...... It's taken me this long to come up with the code!!! - No seriously, I needed an answer to this problem myself a few weeks back, and doing a search on this forum lead me to this 3 year old post, the solution posted was very unsatisfactory (far too big and cumbersome).

"Posting to a website from a midlet", seams to be a problem that could effect many others, so I posted my final solution to the end of this thread, more for reference incase anyone else finds this thread, and are tempted to code up the previous.

tonywestonuk at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

i needed a replacement to the J2SE URLEncoder class, and found this. it's very helpfull, but doesn't work exactly the same. so i modified it a bit, and now it works just like the original;

import java.io.*;

/*

* URLEncoder.java

*

* Created on 21 February 2005, 18:06

*/

/**

* This class encodes strings for sending over HTTP. It replaces the URLEncoder

* class from the J2SE.

* @author yaniv & tsahi <tsahi_75 at yahoo dot com>

*/

public class URLEncoder {

/**

* this function was taken from the Java forums, at

* http://forum.java.sun.com/thread.jspa?forumID=76&messageID=624066&threadID=178903

* and modified to behave like the original one.

* @param s string to encode

* @param enc normally, this would be "UTF8", but here it is ignored.

* @throws IOException on IO error

* @return an encoded version of the string <CODE>s</CODE>

*/

public static String encode(String s, String enc) throws IOException {

ByteArrayOutputStream bOut = new ByteArrayOutputStream();

DataOutputStream dOut = new DataOutputStream(bOut);

StringBuffer ret = new StringBuffer(); //return value

dOut.writeUTF(s);

ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());

bIn.read();

bIn.read();

int c = bIn.read();

while (c >= 0) {

if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')

|| (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '*' || c == '_')

ret.append((char)c);

else if (c == ' ')

ret.append('+');

else {

if (c < 128) {

appendHex(c, ret);

} else if (c < 224) {

appendHex(c, ret);

appendHex(bIn.read(), ret);

} else if (c < 240) {

appendHex(c,ret);

appendHex(bIn.read(), ret);

appendHex(bIn.read(), ret);

}

}

c = bIn.read();

}

return ret.toString();

}

private static void appendHex(int arg0, StringBuffer buff){

buff.append('%');

if (arg0 < 16)

buff.append('0');

buff.append(Integer.toHexString(arg0));

}

}

tsahiAsher at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8
URI encoding explained: http://www.w3.org/International/O-URL-code.htmlJava source: http://www.w3.org/International/URLUTF8Encoder.java
jozart at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 9
Hi,Can you suggest a URLDecoder version that works with your URLEncoder class?Thanks in advance,Michael D.
mishechka at 2007-7-1 20:27:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...