Tools - any_to_utf8

Purpose

The purpose of the any_to_utf8 tool is to mass convert files to UTF-8 format.

Some syntax errors can be due to characters, specific to a certain language. Editing each file is not an option. This tool allows you to convert every file in a given folder to UTF-8.

Applicable in CAST Version

ReleaseYes/No
8.3.x
8.2.x
8.1.x
8.0.x
7.3.x

Applicable RDBMS

RDBMSYes/No
Oracle Server
Microsoft SQL Server
CSS2

Prerequisites

 Follow the below prerequisites before running the tool:

Launch any_to_utf8

Usage

any_to_utf8.py is a Python script, so you need to launch it with Python 3.4 embedded in Cast AIP.

Mandatory arguments :

  • directory : the folder containing the source to process (typically the deployment folder)
  • log : dynamic_to_static log file (not the analysis log)

Open a CMD window, and navigate to the folder where you installed classpath_checker. Type the following command-line :

<INSTALL_FOLDER>\ThirdParty\Python34\python.exe any_to_utf8.py -directory <DEPLOY_FOLDER> -log <DYNAMIC_TO_STATIC_LOG>

Command-line output

any_to_utf8 first looks for files to process based on the regular expression entered as FILE_REGEXP. All files matching the regular expression under the directory argument will be considered.

Then for each file, it tries to open it using each of the known encodings in Python standard module called “encodings”. If successful it just saves it in UTF-8 format.

C:\temp\Tools\any_to_utf8>"c:\Flat Service Packs\8.3.2\ThirdParty\Python34\python.exe" any_to_utf8.py -d "C:\temp\TKB\any_to_utf8\Source" -log C:\temp\TKB\any_to_utf8.log

Searching for files
Found 458 files to process
Opened file C:\temp\TKB\any_to_utf8\Source\webservices\WebServices_FEEAR\META-INF\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\variables.xml
Renamed file C:\temp\TKB\any_to_utf8\Source\webservices\WebServices_FEEAR\META-INF\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\variables.xml into C:\temp\TKB\any_to_utf8\Source\webservices\WebServices_FEEAR\META-INF\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\variables.xml.bak ...
Wrote file C:\temp\TKB\any_to_utf8\Source\webservices\WebServices_FEEAR\META-INF\ibmconfig\cells\defaultCell\applications\defaultApp\deployments\defaultApp\variables.xml...
[...]

Notes/comments

Ticket # 12159

The tool is available here : any_to_utf8.py

Related Pages