public static void writeToStream(String text, Buffer stream) {
		if (text.length() > 80)
			text = text.substring(0, 80);
		text = text.toLowerCase();
		int i = -1;
		for (int c = 0; c < text.length(); c++) {
			char character = text.charAt(c);
			int characterCode = 0;
			for (int l = 0; l < validChars.length; l++) {
				if (character != validChars[l])
					continue;
				characterCode = l;
				break;
			}

			if (characterCode > 12)
				characterCode += 195;
			if (i == -1) {
				if (characterCode < 13)
					i = characterCode;
				else
					stream.put(characterCode);
			} else if (characterCode < 13) {
				stream.put((i << 4) + characterCode);
				i = -1;
			} else {
				stream.put((i << 4) + (characterCode >> 4));
				i = characterCode & 0xf;
			}
		}
		if (i != -1)
			stream.put(i << 4);
	}