Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2001-09-19 19:16:04 +0000
committerCarolyn MacLeod2001-09-19 19:16:04 +0000
commit60ec31511dc79741c1af83d47948f2dad305ae40 (patch)
treec97962fbee416932c4a5ceb3703af0b4d0504f90 /bundles
parentacde7b341a6bea0c6383974b2a02e3a1a71119c4 (diff)
downloadeclipse.platform.swt-60ec31511dc79741c1af83d47948f2dad305ae40.tar.gz
eclipse.platform.swt-60ec31511dc79741c1af83d47948f2dad305ae40.tar.xz
eclipse.platform.swt-60ec31511dc79741c1af83d47948f2dad305ae40.zip
1GK9NGK
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index a5bd47928e..2589c00105 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -461,9 +461,11 @@ char [] getClipboardData () {
if (hMem != 0) {
int ptr = OS.GlobalLock (hMem);
if (ptr != 0) {
- int cchWideChar = OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, ptr, -1, null, 0);
+ /* Use the character encoding for the default locale */
+ int cp = OS.CP_ACP;
+ int cchWideChar = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, ptr, -1, null, 0);
lpWideCharStr = new char [--cchWideChar];
- OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, ptr, -1, lpWideCharStr, cchWideChar);
+ OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, ptr, -1, lpWideCharStr, cchWideChar);
}
}
OS.CloseClipboard ();
@@ -840,7 +842,7 @@ public void insert (String string) {
int mbcsToWcsPos (int mbcsPos) {
if (mbcsPos == 0) return 0;
- int cp = OS.GetACP ();
+ int cp = getCodePage ();
int wcsTotal = 0, mbcsTotal = 0;
byte [] buffer = new byte [128];
String delimiter = getLineDelimiter();
@@ -851,7 +853,9 @@ int mbcsToWcsPos (int mbcsPos) {
int linePos = OS.SendMessage (handle, OS.EM_LINEINDEX, line, 0);
int mbcsSize = OS.SendMessage (handle, OS.EM_LINELENGTH, linePos, 0);
if (mbcsSize != 0) {
- if (mbcsSize > buffer.length) buffer = new byte [mbcsSize + delimiterSize];
+ if (mbcsSize + delimiterSize > buffer.length) {
+ buffer = new byte [mbcsSize + delimiterSize];
+ }
buffer [0] = (byte) (mbcsSize & 0xFF);
buffer [1] = (byte) (mbcsSize >> 8);
mbcsSize = OS.SendMessage (handle, OS.EM_GETLINE, line, buffer);
@@ -1439,7 +1443,7 @@ String verifyText (String string, int start, int end, Event keyEvent) {
int wcsToMbcsPos (int wcsPos) {
if (wcsPos == 0) return 0;
- int cp = OS.GetACP ();
+ int cp = getCodePage ();
int wcsTotal = 0, mbcsTotal = 0;
byte [] buffer = new byte [128];
String delimiter = getLineDelimiter ();
@@ -1450,7 +1454,9 @@ int wcsToMbcsPos (int wcsPos) {
int linePos = OS.SendMessage (handle, OS.EM_LINEINDEX, line, 0);
int mbcsSize = OS.SendMessage (handle, OS.EM_LINELENGTH, linePos, 0);
if (mbcsSize != 0) {
- if (mbcsSize > buffer.length) buffer = new byte [mbcsSize + delimiterSize];
+ if (mbcsSize + delimiterSize > buffer.length) {
+ buffer = new byte [mbcsSize + delimiterSize];
+ }
buffer [0] = (byte) (mbcsSize & 0xFF);
buffer [1] = (byte) (mbcsSize >> 8);
mbcsSize = OS.SendMessage (handle, OS.EM_GETLINE, line, buffer);

Back to the top