Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Windows: Always set codepage explicitely #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ function Manifest(output, path) {
}
}

// Windows codepage
// Optional field, only check if present.
this._windowsCodepage = "";
if (json.xwalk_windows_codepage) {
this._windowsCodepage = json.xwalk_windows_codepage;
} else {
this._windowsCodepage = Manifest.WINDOWS_DEFAULT_CODEPAGE;
}

// Windows update ID
// Optional field, only check if present.
this._windowsUpdateId = null;
Expand Down Expand Up @@ -282,6 +291,13 @@ function Manifest(output, path) {
*/
Manifest.ANDROID_DEFAULT_PERMISSIONS = [ "ACCESS_NETWORK_STATE", "ACCESS_WIFI_STATE", "INTERNET" ];

/**
* Default codepage to use is "western european".
* When using ISO 8859-1 unsupported characters in the manifest,
* the codepage needs to be adjusted accordingly.
*/
Manifest.WINDOWS_DEFAULT_CODEPAGE = "1252";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenchris because Windows (WiX) does not support it for strings that are displayed in the installer UI.

You have "lang" so if "lang": "cn" you can convert UTF-16 to the codepage required for CN. That would be the proper fix

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lang is part of the manifest spec @anssik

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* Create default manifest data.
* @param {String} packageId Unique package identifier com.example.foo
Expand Down Expand Up @@ -332,6 +348,7 @@ function(packageId) {
// Set external storage by default, needed for shared mode/fallback.
"xwalk_android_permissions": Manifest.ANDROID_DEFAULT_PERMISSIONS,
// Windows fields
"xwalk_windows_codepage": Manifest.WINDOWS_DEFAULT_CODEPAGE,
"xwalk_windows_update_id": windowsUpdateId
};
};
Expand Down Expand Up @@ -670,6 +687,18 @@ Object.defineProperty(Manifest.prototype, "targetPlatforms", {
}
});

/**
* Windows codepage
* @member {String} windowsCodepage
* @instance
* @memberOf Manifest
*/
Object.defineProperty(Manifest.prototype, "windowsCodepage", {
get: function() {
return this._windowsCodepage;
}
});

/**
* Windows update ID
* @member {String} windowsUpdateId
Expand Down
22 changes: 22 additions & 0 deletions test/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,28 @@ exports.tests = {
test.done();
},

windowsCodepageDefault: function(test) {

test.expect(1);

var path1 = produceManifest();
var m1 = consumeManifest(path1);

test.equal(m1.windowsCodepage, Manifest.WINDOWS_DEFAULT_CODEPAGE);
test.done();
},

windowsCodepageCustom: function(test) {

test.expect(1);

var path1 = produceManifest({xwalk_windows_codepage: "936"});
var m1 = consumeManifest(path1);

test.equal(m1.windowsCodepage, "936");
test.done();
},

windowsUpdateId: function(test) {

test.expect(1);
Expand Down
3 changes: 2 additions & 1 deletion windows/lib/WixSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function(app_path, xwalk_path, meta_data, callback) {
'UpgradeCode': meta_data.upgrade_id,
'Version': meta_data.version,
'Manufacturer': meta_data.manufacturer,
'Language': '1033'
'Language': '1033',
'Codepage': this._manifest.windowsCodepage
});

var package = product.ele('Package', { InstallerVersion: '300', 'Compressed': 'yes' });
Expand Down