diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:41:49 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-04-02 14:58:00 -0700 |
| commit | 4449fcc5b8d104817c67135229682c66c3d892ca (patch) | |
| tree | 327f617de2e296ddb4e62c50bf07ec8b5dcf0a3e /src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs | |
| parent | 9cca339473d77c7036035f949239f5231c325968 (diff) | |
| download | wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.gz wix-4449fcc5b8d104817c67135229682c66c3d892ca.tar.bz2 wix-4449fcc5b8d104817c67135229682c66c3d892ca.zip | |
Enable codepages and languages to be set via .wxl files
Fixes wixtoolset/issues#5801
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs index f09a2e47..ff03413c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs | |||
| @@ -36,23 +36,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 36 | public void Execute() | 36 | public void Execute() |
| 37 | { | 37 | { |
| 38 | // write out the table to an IDT file | 38 | // write out the table to an IDT file |
| 39 | Encoding encoding; | 39 | var encoding = GetCodepageEncoding(this.Codepage); |
| 40 | |||
| 41 | // If UTF8 encoding, use the UTF8-specific constructor to avoid writing | ||
| 42 | // the byte order mark at the beginning of the file | ||
| 43 | if (this.Codepage == Encoding.UTF8.CodePage) | ||
| 44 | { | ||
| 45 | encoding = new UTF8Encoding(false, true); | ||
| 46 | } | ||
| 47 | else | ||
| 48 | { | ||
| 49 | if (this.Codepage == 0) | ||
| 50 | { | ||
| 51 | this.Codepage = Encoding.ASCII.CodePage; | ||
| 52 | } | ||
| 53 | |||
| 54 | encoding = Encoding.GetEncoding(this.Codepage, new EncoderExceptionFallback(), new DecoderExceptionFallback()); | ||
| 55 | } | ||
| 56 | 40 | ||
| 57 | this.IdtPath = Path.Combine(this.IntermediateFolder, String.Concat(this.Table.Name, ".idt")); | 41 | this.IdtPath = Path.Combine(this.IntermediateFolder, String.Concat(this.Table.Name, ".idt")); |
| 58 | 42 | ||
| @@ -209,6 +193,30 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 209 | .Replace('\n', '\x19'); | 193 | .Replace('\n', '\x19'); |
| 210 | } | 194 | } |
| 211 | 195 | ||
| 196 | private static Encoding GetCodepageEncoding(int codepage) | ||
| 197 | { | ||
| 198 | Encoding encoding; | ||
| 199 | |||
| 200 | // If UTF8 encoding, use the UTF8-specific constructor to avoid writing | ||
| 201 | // the byte order mark at the beginning of the file | ||
| 202 | if (codepage == Encoding.UTF8.CodePage) | ||
| 203 | { | ||
| 204 | encoding = new UTF8Encoding(false, true); | ||
| 205 | } | ||
| 206 | else | ||
| 207 | { | ||
| 208 | if (codepage == 0) | ||
| 209 | { | ||
| 210 | codepage = Encoding.ASCII.CodePage; | ||
| 211 | } | ||
| 212 | |||
| 213 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | ||
| 214 | |||
| 215 | encoding = Encoding.GetEncoding(codepage, new EncoderExceptionFallback(), new DecoderExceptionFallback()); | ||
| 216 | } | ||
| 217 | |||
| 218 | return encoding; | ||
| 219 | } | ||
| 212 | 220 | ||
| 213 | /// <summary> | 221 | /// <summary> |
| 214 | /// Gets the type of the column in IDT format. | 222 | /// Gets the type of the column in IDT format. |
