Unifier can operate in Unattended mode (i.e. command-line mode). It can be used as helper application to convert encoding of text or HTML files.
Unifier requires various parameters to perform the conversion. For examples, the encoding of source file, output options and Unicode format. It would be rather complicated if all these parameters are provided from command line switch. To simplify the provisioning of parameters, Unifier uses a data file called Unifier Config Profile (.ucp) to obtain the settings.
A small program called xunifier.exe is available to use Unifier in command-line mode. xunifier.exe is just a simple front-end program. It calls unifier.exe to do the actual conversion.
Procedure for Unattended mode Operation
The procedure of unattended mode operation is listed as follows. Each step will be discussed in details in the following session
Step 1: Create Config Profile from GUI mode
Step 2: Perform the conversion from command line mode
Step 3: Get the conversion result
Step 1: Create Config Profile
Config Profile is used to provide the setting to Unifier during conversion in unattended mode. You need to create Config Profile in GUI mode.
1. Launch Unifier
2. Configure your setting such as encoding, output options from Unifier Window
3. (Optional) Test your configuration from GUI mode
4. Select Save Configuration As from File menu
5. Specify the filename from the File Dialog Box and click Save button
Note: The Config Profile is also used in GUI mode to ease configuration of Unifier. Please refer to Using Config Profile session.
Step 2: Command Line Mode
A small application xunifier.exe is provided to operate Unifier in command-line mode. The command line arguments are as follows.
xunifier /c <cfg-profile> [/l logfile] [/o] [y] <files to convert...>
/c cfg-profile - The config profile used to perform the conversion
/l logfile - The filename of Log File. Default: unifier.log
/o - Overwrite the Log File. Default: Append to existing log file
/y - Overwrite the destination file if the file already exists.
Default: Skip the file
/s - Search files in sub-directories
/c <cfg-profile>
The /c switch specifies the config profile used during conversion. This switch is mandatory in command line mode. <cfg-profile> should be the pathname to a Unifier Config Profile (*.ucp).
/l <logfile>
The /l switch is optional and its specify the log file. If this switch is omitted, Unifier will use the default log file  unifier.log.
/o Overwrite Log File Swtich
Optional. If /o switch is specified, Unifier will overwrite the log file if it already exists. Otherwise, Unifier will append to current file.
/y Overwrite Output File Switch
Optional. If the destination files already exist, the default action of Unifier is to skip those files. If /y switch is specified, Unifier will overwrite the files.
/s Search Sub-directories Switch
Optional. If /s switch is specified, Unifier would search files in all sub-directories
Tips: If there is any space character in a pathname, you have to put double quotes (") characters around the pathname.
Step 3: Get the conversion result
xunifier.exe will print out error message if there is critical error during conversion. A detailed report will be written to the log file. If you have not specified a log file using /l switch, the default one is unifier.log.
Please check the log file if xunifier reports that there is any error or warning during conversion.
Example
To convert readme.txt file to Unicode using japanese.ucp as config profile and write the log to testing.log, please use this command:
You may use wildcard characters (* or ?) in filename to specify the files to be converted. Unifier will try to search the files and convert all of them. Wildcard characters can be used in both GUI mode and unattended mode. You may also use /s switch to search files in sub-directories.
Example
xunifier /c japanese.ucp y*.htm y*.php
xunifier exit code
If you need to capture the conversion result and perform further action, you may use the exit code of xunifier. If a DOS batch file is used, you may use ERRORLEVEL variable to obtain the conversion result. The exit code is listed as follows.
160 There is error during conversion. Please read the log file.
155 Failed to save log file
150 "Output to a folder" specified in configuration profile is invalid.
148 "Add a filename prefix to converted files" setting is invalid.
146 "Overwrite after backup original files" setting is invalid.
144 The Code Page specified in configuration profile is not supported by this computer
142 No source file is specified in the command line argument
140 The configuration profile is invalid or inaccessible
134 The Log file is not specified following the /l switch
132 No Configuration profile is specified. Please check the /c switch
130 Unknown command line switch is specified
16 There is warning during conversion. Please read the log file. (But the source file is converted)
0 Conversion OK, No Error
In general, the result code will be assigned as follows.
Exit Code Range
Description
128--255
Error Level
1-127
Warning Level
0
OK
What does xunifier do?
xunifier.exe is just a tiny application. It performs the following actions.
Step 1) It finds the location of unifier.exe by reading the following entry in Windows registry
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\unifier.exe
Step 2) It adds a "/u" switch to the command-line arguments provided to xunifier.exe
Step 3) It calls unifier.exe to do the conversion
Step 4) It captures the exit code of Unifier. Then, print out error message if necessary
Step 5) It returns the exit code of Unifier as its own exit code.