Skip to main content
summaryrefslogtreecommitdiffstats
blob: 682f69081f15fa852b1ccc74ee35ae83553a19eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.eclipse.swt.internal;

/*
 * Licensed Materials - Property of IBM,
 * (c) Copyright IBM Corp. 1998, 2000  All Rights Reserved
 */
 
public final class Converter {
	public static final byte [] NullByteArray = new byte [1];
	public static final char [] NullCharArray = new char [1];
	public static final byte [] EmptyByteArray = new byte [0];
	public static final char [] EmptyCharArray = new char [0];
public static String defaultCodePage () {
	/*
	| ptr cp |
	DefaultCodePage == nil ifFalse: [^DefaultCodePage].
	cp := ''. "$NON-NLS$"
	(ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull
		ifFalse: [cp := String copyFromOSMemory: ptr].
	cp isEmpty ifFalse: [
		IsSunOS ifTrue: [
			(cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])
				ifTrue: [cp := cp copyFrom: 4 to: cp size]].
		^DefaultCodePage := cp].
	IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].
	IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].
	^DefaultCodePage := 'iso8859_1'
	*/
	return null;
}
static boolean is7BitAscii (byte [] buffer) {
	for (int i=0; i<buffer.length; i++) {
		if ((buffer [i] & 0xFF) > 0x7F) return false;
	}
	return true;
}
static boolean is7BitAscii (char [] buffer) {
	for (int i=0; i<buffer.length; i++) {
		if (buffer [i] > 0x7F) return false;
	}
	return true;
}
public static char [] mbcsToWcs (String codePage, byte [] buffer) {
	//SLOW AND BOGUS
	return new String (buffer).toCharArray ();
}
/* TEMPORARY CODE */
public static byte [] wcsToMbcs (String codePage, String string) {
	return wcsToMbcs (codePage, string, false);
}
public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
	//SLOW AND BOGUS
	int count = string.length ();
	if (terminate) count++;
	char [] buffer = new char [count];
	string.getChars (0, string.length (), buffer, 0);
	return wcsToMbcs (codePage, buffer, false);
}
/* TEMPORARY CODE */
public static byte [] wcsToMbcs (String codePage, char [] buffer) {
	return wcsToMbcs (codePage, buffer, false);
}
public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
	//SLOW AND BOGUS
	if (!terminate) return new String (buffer).getBytes ();
	byte [] buffer1 = new String (buffer).getBytes ();
	byte [] buffer2 = new byte [buffer1.length + 1];
	System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
	return buffer2;
}
}

Back to the top