Jump to content
Sign in to follow this  
majstang

ANSI to UTF-8 Converter UTF-8 to ANSI Converter

Recommended Posts

majstang

Recording Service is now migrated to Unicode. However there is still quite many files in it still using ANSI encoding e.g. RS .log files and most of the config files. While the EPG information file .txt is UTF-8 (Unicode). I don't know the reason for it, but i guess converting all files (source code) would be lots of work not entirely needed in order for RS to functioning alright. If you like to make scripts for RS to automate boring and repetive tasks...simply make your life easier you soon will run into trouble with these Unicode and ANSI files in different scenarios. Getting strange characters all over the place. Using RS files in third party software not supporting Unicode. In these cases it might be handy having some conversion tools.

 

They are easy to use. Just drag and drop the file which is to be converted onto the script and it will be converted. Install Autohotkey_L (Unicode) to get the scripts to work.

 

The output of the ANSI to UTF-8 script is a UTF-8 encoded file without Byte Order Mark (BOM). That means the file is safe to be used with RS and DVBViewer without causing any garabage characters, provided this particular file was unicode from the beginning. If re-using converted files into RS it's important to keep track of the files original encoding. Putting in an ANSI file which was supposed to be UTF-8 encoded, could cause much trouble. So use the scripts with causion and at own risk.

 

If editing and/or changing encoding for RS files with texteditors use Notepad++ only. Always save UTF-8 files in Notepad++ with the "UTF-8 without BOM" option. Most of the other texteditors adds a BOM when saving the file and if re-using them with RS will be problematic. Simply put this encoding stuff is a jungle...it's very easy to make misstakes, which will take hours to figure out and fix.

 

UTF-8 to ANSI CONVERTER

Loop %0%  ; For each parameter (or file dropped onto a script):
{
   GivenPath := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
   FileRead, UTF, *P65001 %GivenPath%
   FileDelete, %GivenPath% 
   FileAppend, %UTF%, %GivenPath%, CP0
}

ANSI to UTF-8 CONVERTER

Loop %0%  ; For each parameter (or file dropped onto a script):
{
   GivenPath := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
   FileRead, ANSI, *P0 %GivenPath%
   FileDelete, %GivenPath% 
   FileAppend, %ANSI%, %GivenPath%, UTF-8-RAW
}

Edited by majstang

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...