Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2001-08-29 21:12:35 +0000
committerSilenio Quarti2001-08-29 21:12:35 +0000
commite29ca99d663ea45a45997469b2ad973b95cb79d0 (patch)
tree918630094138f91db7ec51c685214c21df86ca25 /bundles
parent6f4503090b247795a19e8669b7c6bcd55ff1eb17 (diff)
downloadeclipse.platform.swt-e29ca99d663ea45a45997469b2ad973b95cb79d0.tar.gz
eclipse.platform.swt-e29ca99d663ea45a45997469b2ad973b95cb79d0.tar.xz
eclipse.platform.swt-e29ca99d663ea45a45997469b2ad973b95cb79d0.zip
ssq - codepage work
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java42
6 files changed, 97 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
index dd6d8e87d8..63c3318a85 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
@@ -359,6 +359,7 @@ public static String findProgramID (String extension) {
if (extension.charAt (0) != '.') extension = "." + extension;
+ /* Use the character encoding for the default locale */
byte[] extensionKey = Converter.wcsToMbcs(0, extension, true);
String result = getKeyValue(extensionKey);
if (result != null) {
@@ -385,6 +386,7 @@ private static String getKeyValue (byte [] key) {
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
byte [] lpData = new byte [lpcbData [0]];
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ /* Use the character encoding for the default locale */
char[] charArray = Converter.mbcsToWcs (0, lpData);
result = new String(charArray, 0, charArray.length - 1);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
index 86e53a1b83..a59c5d6b84 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
@@ -186,6 +186,7 @@ public Printer(PrinterData data) {
*/
protected void create(DeviceData deviceData) {
data = (PrinterData)deviceData;
+ /* Use the character encoding for the default locale */
byte[] driver = Converter.wcsToMbcs(0, data.driver, true);
byte[] device = Converter.wcsToMbcs(0, data.name, true);
int lpInitData = 0;
@@ -272,6 +273,7 @@ public boolean startJob(String jobName) {
int hHeap = OS.GetProcessHeap();
int lpszDocName = 0;
if (jobName != null && jobName.length() != 0) {
+ /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(0, jobName, true);
lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
OS.MoveMemory(lpszDocName, buffer, buffer.length);
@@ -279,6 +281,7 @@ public boolean startJob(String jobName) {
}
int lpszOutput = 0;
if (data.printToFile && data.fileName != null) {
+ /* Use the character encoding for the default locale */
byte [] buffer = Converter.wcsToMbcs(0, data.fileName, true);
lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
OS.MoveMemory(lpszOutput, buffer, buffer.length);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index d210445b81..ce917ea12f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -43,6 +43,7 @@ public static Program findProgram (String extension) {
if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (extension.length () == 0) return null;
if (extension.charAt (0) != '.') extension = "." + extension;
+ /* Use the character encoding for the default locale */
byte [] key = Converter.wcsToMbcs (0, extension, true);
int [] phkResult = new int [1];
if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
@@ -71,6 +72,7 @@ public static String [] getExtensions () {
while (length < key.length && key [length] != 0) length++;
byte [] buffer = new byte [length];
System.arraycopy (key, 0, buffer, 0, length);
+ /* Use the character encoding for the default locale */
String extension = new String (Converter.mbcsToWcs (0, buffer));
if (count == extensions.length) {
String [] newExtensions = new String [extensions.length + 1024];
@@ -99,6 +101,7 @@ static String getKeyValue (byte [] key) {
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
byte [] lpData = new byte [lpcbData [0]];
if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ /* Use the character encoding for the default locale */
char [] charArray = Converter.mbcsToWcs (0, lpData);
result = new String (charArray, 0, charArray.length - 1);
}
@@ -110,6 +113,7 @@ static String getKeyValue (byte [] key) {
static Program getProgram (byte [] key) {
/* Command */
+ /* Use the character encoding for the default locale */
byte [] COMMAND = Converter.wcsToMbcs (0, "\\shell\\open\\command", true);
int length = 0;
while (length < key.length && key [length] != 0) length++;
@@ -124,6 +128,7 @@ static Program getProgram (byte [] key) {
if (name == null || name.length () == 0) return null;
/* Icon */
+ /* Use the character encoding for the default locale */
byte [] DEFAULT_ICON = Converter.wcsToMbcs (0, "\\DefaultIcon", true);
for (int i=0; i<DEFAULT_ICON.length; i++) key [length + i] = DEFAULT_ICON [i];
key [length + DEFAULT_ICON.length] = 0;
@@ -180,6 +185,7 @@ public static Program [] getPrograms () {
*/
public static boolean launch (String fileName) {
if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ /* Use the character encoding for the default locale */
byte [] OPEN = Converter.wcsToMbcs (0, "open", true);
byte [] lpFile = Converter.wcsToMbcs (0, fileName, true);
return OS.ShellExecute (0, OPEN, lpFile, null, null, OS.SW_SHOW) > 32;
@@ -241,6 +247,7 @@ public ImageData getImageData () {
nIconIndex = Integer.parseInt (iconIndex);
} catch (NumberFormatException e) {};
}
+ /* Use the character encoding for the default locale */
byte [] lpszFile = Converter.wcsToMbcs (0, fileName, true);
int [] phiconSmall = new int[1], phiconLarge = null;
OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
index ac4958afe4..977b0e02a7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
@@ -6,6 +6,7 @@ package org.eclipse.swt.graphics;
*/
import org.eclipse.swt.*;
+import java.util.Locale;
/**
* Instances of this class describe operating system fonts.
@@ -103,6 +104,12 @@ public final class FontData {
* Warning: This field is platform dependent.
*/
public String characterSetName;
+
+ /**
+ * The locale of the font
+ * (Warning: This field is platform dependent)
+ */
+ Locale locale;
/**
* Constructs a new un-initialized font data.
*/
@@ -381,6 +388,15 @@ public void setName(String name) {
fontFamily = name;
}
}
+/**
+ * Sets the locale of the receiver.
+ *
+ * @param locale the Locale of the <code>FontData</code>
+ *
+ */
+public void setLocale(Locale locale) {
+ this.locale = locale;
+}
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
index aece68e79c..492c0e7972 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
@@ -29,6 +29,33 @@ public class OS {
/* OLE Constants */
public static final int S_OK = 0;
+ /* Charset Constants */
+// public static final int ANSI_CHARSET = 0;
+ public static final int DEFAULT_CHARSET = 1;
+// public static final int SYMBOL_CHARSET = 2;
+// public static final int SHIFTJIS_CHARSET = 128;
+// public static final int HANGEUL_CHARSET = 129;
+// public static final int GB2312_CHARSET = 134;
+// public static final int CHINESEBIG5_CHARSET = 136;
+// public static final int OEM_CHARSET = 255;
+// public static final int JOHAB_CHARSET = 130;
+// public static final int HEBREW_CHARSET = 177;
+// public static final int ARABIC_CHARSET = 178;
+// public static final int GREEK_CHARSET = 161;
+// public static final int TURKISH_CHARSET = 162;
+// public static final int VIETNAMESE_CHARSET = 163;
+// public static final int THAI_CHARSET = 222;
+// public static final int EASTEUROPE_CHARSET = 238;
+// public static final int RUSSIAN_CHARSET = 204;
+// public static final int MAC_CHARSET = 77;
+// public static final int BALTIC_CHARSET = 186;
+
+ /* Locale Constants */
+ public static final int LCID_SUPPORTED = 0x00000002;
+ public static final int LOCALE_SISO3166CTRYNAME = 0x0000005A;
+ public static final int LOCALE_SISO639LANGNAME = 0x00000059;
+ public static final int LOCALE_IDEFAULTANSICODEPAGE = 0x00001004;
+
/* Window Constants */
public static final int COLOR_BTNFACE = 15;
public static final int COLOR_BTNHIGHLIGHT = 20;
@@ -820,7 +847,6 @@ public class OS {
// public static final int DCX_PARENTCLIP = 0x20;
// public static final int DCX_VALIDATE = 0x200000;
// public static final int DCX_WINDOW = 0x1;
- public static final int DEFAULT_CHARSET = 1;
public static final int DEFAULT_GUI_FONT = 0x11;
// public static final int DEFAULT_PALETTE = 0xF;
// public static final int DEVICE_DEFAULT_FONT = 0xE;
@@ -3132,6 +3158,8 @@ public class OS {
// public static final int TC_SO_ABLE = 0x1000;
// public static final int TC_UA_ABLE = 0x800;
// public static final int TC_VA_ABLE = 0x4000;
+ public static final int TCI_SRCCHARSET = 1;
+ public static final int TCI_SRCCODEPAGE = 2;
public static final int TCIF_IMAGE = 0x0002;
// public static final int TCIF_PARAM = 0x0008;
// public static final int TCIF_RTLREADING = 0x0004;
@@ -4478,4 +4506,9 @@ public static final native int GetKeyboardLayout(int idThread);
public static final native int ActivateKeyboardLayout(int hkl, int Flags);
public static final native int SetTextAlign(int hdc, int fMode);
+public static final native boolean TranslateCharsetInfo(int lpSrc, int [] lpCs, int dwFlags);
+public static final native int GetTextCharset(int hdc);
+public static final native int GetLocaleInfo(int Locale, int LCType, byte[] lpLCData, int cchData);
+public static final native boolean EnumSystemLocales(int lpLocaleEnumProc, int dwFlags);
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 87066e6165..8fbaf377e3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -584,14 +584,27 @@ boolean isValidThread () {
}
/*
- * Returns a single character, converted from the multi-byte
- * character set (MBCS) used by the operating system widgets
- * to a wide character set (WCS) used by Java.
+ * Returns a single character, converted from the default
+ * multi-byte character set (MBCS) used by the operating
+ * system widgets to a wide character set (WCS) used by Java.
*
* @param ch the MBCS character
* @return the WCS character
*/
char mbcsToWcs (char ch) {
+ return mbcsToWcs (ch, 0);
+}
+
+/*
+ * Returns a single character, converted from the specified
+ * multi-byte character set (MBCS) used by the operating
+ * system widgets to a wide character set (WCS) used by Java.
+ *
+ * @param ch the MBCS character
+ * @param codePage the code page used to convert the character
+ * @return the WCS character
+ */
+char mbcsToWcs (char ch, int codePage) {
int key = ch & 0xFFFF;
if (key <= 0x7F) return ch;
byte [] buffer;
@@ -603,7 +616,7 @@ char mbcsToWcs (char ch) {
buffer [0] = (byte) ((key >> 8) & 0xFF);
buffer [1] = (byte) (key & 0xFF);
}
- char [] result = Converter.mbcsToWcs (0, buffer);
+ char [] result = Converter.mbcsToWcs (codePage, buffer);
if (result.length == 0) return 0;
return result [0];
}
@@ -941,16 +954,31 @@ public String toString () {
}
/*
* Returns a single character, converted from the wide
- * character set (WCS) used by Java to the multi-byte
- * character set used by the operating system widgets.
+ * character set (WCS) used by Java to the default
+ * multi-byte character set used by the operating system
+ * widgets.
*
* @param ch the WCS character
* @return the MBCS character
*/
char wcsToMbcs (char ch) {
+ return wcsToMbcs (ch, 0);
+}
+
+/*
+ * Returns a single character, converted from the wide
+ * character set (WCS) used by Java to the specified
+ * multi-byte character set used by the operating system
+ * widgets.
+ *
+ * @param ch the WCS character
+ * @param codePage the code page used to convert the character
+ * @return the MBCS character
+ */
+char wcsToMbcs (char ch, int codePage) {
int key = ch & 0xFFFF;
if (key <= 0x7F) return ch;
- byte [] buffer = Converter.wcsToMbcs (0, new char [] {ch}, false);
+ byte [] buffer = Converter.wcsToMbcs (codePage, new char [] {ch}, false);
if (buffer.length == 1) return (char) buffer [0];
if (buffer.length == 2) {
return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));

Back to the top