summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2006-03-17 23:27:59 +0000
committerGrant Gayed <ggayed>2006-03-17 23:27:59 +0000
commit69ca5330829dc12b4ee79a2f425dddecd4d5dca3 (patch)
tree1a2e7a8888326fdd1c86ca5f2ea51ef18aa47534
parent83ae7ec2e6d2305056c75d3509268f2018b8a96a (diff)
downloadeclipse.platform.swt-69ca5330829dc12b4ee79a2f425dddecd4d5dca3.tar.gz
eclipse.platform.swt-69ca5330829dc12b4ee79a2f425dddecd4d5dca3.tar.xz
eclipse.platform.swt-69ca5330829dc12b4ee79a2f425dddecd4d5dca3.zip
77456
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/motif/org/eclipse/swt/browser/Browser.java44
1 files changed, 37 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/motif/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/motif/org/eclipse/swt/browser/Browser.java
index d628b487b7..0012f36062 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/motif/org/eclipse/swt/browser/Browser.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/motif/org/eclipse/swt/browser/Browser.java
@@ -79,6 +79,7 @@ public class Browser extends Composite {
static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$
+ static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$
static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$
static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$
@@ -218,10 +219,10 @@ public Browser(Composite parent, int style) {
windowWatcher.Release();
/*
- * As a result of not using profiles, the user's locale defaults
- * to en_us, which is not the correct value for users in other
- * locales. The fix for this is to set mozilla's locale preference
- * value according to the user's current locale.
+ * As a result of not using profiles, the user's locale and charset default
+ * to en_us and iso-8859-1, which are not the correct values for users in
+ * other locales. The fix for this is to set mozilla's locale and charset
+ * preference values according to the user's current locale and charset.
*/
buffer = XPCOM.NS_PREFSERVICE_CONTRACTID.getBytes();
aContractID = new byte[buffer.length + 1];
@@ -241,12 +242,13 @@ public Browser(Composite parent, int style) {
nsIPrefBranch prefBranch = new nsIPrefBranch(result[0]);
result[0] = 0;
+
+ /* get Mozilla's current locale preference value */
buffer = Converter.wcsToMbcs(null, PREFERENCE_LANGUAGES, true);
rc = prefBranch.GetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
if (rc != XPCOM.NS_OK) error(rc);
if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
- /* get Mozilla's current locale preference value */
nsIPrefLocalizedString localizedString = new nsIPrefLocalizedString(result[0]);
result[0] = 0;
rc = localizedString.ToString(result);
@@ -261,7 +263,7 @@ public Browser(Composite parent, int style) {
* construct the new locale preference value by prepending the
* user's current locale and language to the original value
*/
- Locale locale = java.util.Locale.getDefault();
+ Locale locale = Locale.getDefault();
String language = locale.getLanguage();
String country = locale.getCountry();
StringBuffer stringBuffer = new StringBuffer (language);
@@ -281,7 +283,7 @@ public Browser(Composite parent, int style) {
}
newLocales = stringBuffer.toString();
if (!newLocales.equals(prefLocales)) {
- /* write the new value */
+ /* write the new locale value */
newLocales = newLocales.substring(0, newLocales.length() - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */
length = newLocales.length();
char[] charBuffer = new char[length + 1];
@@ -291,6 +293,34 @@ public Browser(Composite parent, int style) {
if (rc != XPCOM.NS_OK) error(rc);
}
localizedString.Release();
+
+ /* get Mozilla's current charset preference value */
+ buffer = Converter.wcsToMbcs(null, PREFERENCE_CHARSET, true);
+ rc = prefBranch.GetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+ if (rc != XPCOM.NS_OK) error(rc);
+ if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
+
+ localizedString = new nsIPrefLocalizedString(result[0]);
+ result[0] = 0;
+ rc = localizedString.ToString(result);
+ if (rc != XPCOM.NS_OK) error(rc);
+ if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
+ length = XPCOM.strlen_PRUnichar(result[0]);
+ dest = new char[length];
+ XPCOM.memmove(dest, result[0], length * 2);
+ String prefCharsets = new String(dest);
+
+ String newCharset = System.getProperty("file.encoding"); // $NON-NLS-1$
+ if (!newCharset.equals(prefCharsets)) {
+ /* write the new charset value */
+ length = newCharset.length();
+ char[] charBuffer = new char[length + 1];
+ newCharset.getChars(0, length, charBuffer, 0);
+ localizedString.SetDataWithLength(length, charBuffer);
+ rc = prefBranch.SetComplexValue(buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress());
+ if (rc != XPCOM.NS_OK) error(rc);
+ }
+ localizedString.Release();
prefBranch.Release();
PromptServiceFactory factory = new PromptServiceFactory();