![]() |
#1 |
Moderator
|
NSIS UTF-8 to ANSI conversion problem
I was so stupid and decided to add support for Chinese language in my project
![]() I thought it will be nice and easy - I was wrong! It seems that there are problems I can not resolve myself. So, I will try do describe the problem and I hope some of you guys can help me. My NSIS Installer (Unicode) uses UTF-8 (No BOM) encoded language files. The file contains all strings that I use to display in installer pages and to generate files on user PC during installation (configuration files). My NSIS installer with Chinese language with UTF-8 encoding works fine - everything is displayed correctly (my Chinese translator says it is OK). But, the problem is with files that I generate on runtime during installation process on user PC (the files need to be generated dynamically as its content depends on user selection during installation). So, I was trying to use what NSIS offer - as far as I know NSIS support "FileWrite" and "FileWriteUTF16LE" commands. Write below strings to file. LangString UFM_COMPILE_DATE ${LANG_ID} "构建日期: " ; Built Date: LangString UFM_INSTALL_DATE ${LANG_ID} "安装日期:" ; Installation date: LangString UFM_INSTALL_PATH ${LANG_ID} "安装目录:" ; Installation Directory: 1. FileWrite creates ANSI file: PHP Code:
2. FileWriteUTF16LE creates Unicode (UTF-16LE) file: PHP Code:
But, regardless of whether it's a TC program fault or encoding conversion I can not use this. So, Chinese translator said only ANSI GB2312 (Simplified) works fine. Finally, the question is how to write (generate) file with ANSI GB2312 (Simplified) encoding using NSIS with UTF-8 (NO BOM) language file. - Example NSIS Language file (with input strings): http://www.meggamusic.co.uk/shup/154...IMPCHINESE.nsh - Example Output Chinese file: http://www.meggamusic.co.uk/shup/154...IMPCHINESE.MNU Is this possible to create with NSIS a file encoded as ANSI GB2312 (Simplified) using UTF-8 (No BOM) encoded language file? How can I do this? Any help is much appreciated! I am lost with this Chinese magic :P -Pawel PLEASE DONATE Projects: My Website | NSIS PL | Winamp PL | Winamp Help (PL) | Ultimate File Manager Winamp translations: Oficjalny Polski Pakiet Językowy (Official Polish Language Pack) Other Winamp projects: Winamp Color Themes | Winamp Icon Packs Winamp Tools: Winamp Tools (All About Winamp | Winamp Backup & Restore | Winamp Translation) |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,446
|
0)
Why are your .nsh files without BOM? 1) FileWrite will never work on anything except "Chinese" machines, it is documented to convert the string to ACP ANSI. 2) That file does not have a BOM, use FileWriteUTF16LE /BOM $R0 "" before writing the strings. Most editors that can read UTF-16 will support the BOM on these files. (Technically, all editors that can read UTF-16 can also read the BOM because it is a valid Unicode character but they might not recognize it as a BOM and switch to UTF-16 automatically) ?) To write in a custom codepage you must do the conversion and writing yourself: PHP Code:
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 | |||
Moderator
|
Anders,
First of all - thank you for your answer and time you spent to help me. No reason. It works fine without BOM so I didn't touch it. I will try to change it and use BOM in future. Quote:
Quote:
![]() Quote:
I will test it and I hope this will resolve all my problems. -Pawel PLEASE DONATE Projects: My Website | NSIS PL | Winamp PL | Winamp Help (PL) | Ultimate File Manager Winamp translations: Oficjalny Polski Pakiet Językowy (Official Polish Language Pack) Other Winamp projects: Winamp Color Themes | Winamp Icon Packs Winamp Tools: Winamp Tools (All About Winamp | Winamp Backup & Restore | Winamp Translation) |
|||
![]() |
![]() |
![]() |
#4 |
Moderator
|
Anders,
I made few tests and it seems to work fine. Thanks! This will make all things much easier. Now, I will only have to implement it. -Pawel PLEASE DONATE Projects: My Website | NSIS PL | Winamp PL | Winamp Help (PL) | Ultimate File Manager Winamp translations: Oficjalny Polski Pakiet Językowy (Official Polish Language Pack) Other Winamp projects: Winamp Color Themes | Winamp Icon Packs Winamp Tools: Winamp Tools (All About Winamp | Winamp Backup & Restore | Winamp Translation) |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|