ZTree.com  | ZEN  | About...  

 Index   Back

[Discuss] INI file management from command line?   [Discuss]

By: Art Kocsis     So Calif  
Date: Sep 11,2017 at 01:11
In Response to: [Discuss] INI file management from command line? (Slobodan Vujnovic)

Au Contraire! Then the obvious thing is to simply convert the Unicode text to ANSI.

Unix/Linux has a little command line tool, IConv, that does just that. Actually, it will convert a multitude of char encoding from one to another and has been ported to Windows. Google iconv+windows

See: https://dbaportal.eu/2012/10/24/iconv-for-windows/ for instructions

However, this semi-port is a bit of overkill for simply converting Unicode to ANSI as the installation yields 11 files using over 1MB of disk space. There is supposed to be a true windows port of IConv called Win-IConv but finding a binary proved to be difficult although the source is readily available at github. Another purported "portable" solution, GetText, turned out to be a huge tree taking up almost 100 MB of space! (In fairness, though, it is an entire multi-language translation package.)

This has now become a challenge. How difficult can it be to write a program to copy a file and discard every other byte? It must be a common task so why aren't there lots of utils available to do it? In frustration I did what I should have done in the first place: Google convert+"UNicode to ANSI"

Finally! Turns out to be much simpler than I thought: The tried and true legacy DOS TYPE command found on all (32 bit only?), windows machines converts to and from ASCII to Unicode! Simply TYPE the file and redirect stdout to a new file! Duh!!! (The conversion from ANSI to Unicode is slightly more complicated. See Rob VanderWoude's page.)

Type Unicode.txt > ASCII.txt

To include extended ASCII characters, reset the current Code Page to 1252:

CHCP 1252 & Type Unicode.txt > ANSI.txt

Putting it all together with the previous (or just use the last line):


<<<<<<<<<<<<<<<<<<<<<<<<<< Code start >>>>>>>>>>>>>>>>>>>>>>>>>
:: Command file to extract and sort ini file section titles
Set bgn=%date:~-2,2%-%date:~0,2%-%date:~3,2% %time:~0,2%:%time:~3,2%
Set bgn=%bgn: = 0%
Echo Date Time: %bgn% > "%~n1.xtr"
Echo Ini Source: %1 >> "%~n1.xtr"
Echo Ini Sections: >> "%~n1.xtr"
Echo ================ >> "%~n1.xtr"
CHCP 1252 & Type Unicode.txt | Findstr /b /c:[ "%1" | Sort >> "%~n1.xtr" 2>&1
<<<<<<<<<<<<<<<<<<<<<<<<<< Code End >>>>>>>>>>>>>>>>>>>>>>>>>

If TYPE is not available, StringConverter is an alternate freeware console tool that is still available via the Wayback Machine. I haven't tried it but it was recommended on a forum (link below).

So in spite of all the upturned noses of the GUI only users, those who need or want to work efficiently make good and extensive use of command line resources (and If they are really smart, they are also ZTree users!)

Refs (Freeware unless otherwise noted):
=============================
Convert Unicode files to ANSI (StringConverter, V - The File Viewer, Type)
https://forums.techguy.org/threads/solve...convert-unicode-files-to-ansi.804289/
The TYPE command
http://www.robvanderwoude.com/type.php#Unicode
http://www.dostips.com/?t=Snippets.UnicodeToAnsi
StringConverter (command line convert a FILE or a string from/to ANSI, OEM, BASE64, UNICODE)
https://web.archive.org/web/201208290121...rdier.com/gbtools/stringconverter.htm
Universal Viewer (freeware version available, has been mentioned here many times, GUI only?)
http://www.uvviewsoft.com/uviewer/
V - The File Viewer (Extensive command line support, $20 but looks very impressive, also other utils)
http://www.fileviewer.com/Features.html
IConv
https://en.wikipedia.org/wiki/Iconv
ICONV for Windows (Unix util, DL links & installation instructions, 11 files/1 MB, incls GetText.exe)
https://dbaportal.eu/2012/10/24/iconv-for-windows/
Win-IConv (source code only)
https://github.com/win-iconv/win-iconv
GetText and IConv Binaries for Windows (full translations for 37 locales, 98 MB instl)
http://mlocati.github.io/articles/gettext-iconv-windows.html
A Quick Gettext Tutorial
http://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html

Sheeesh. this was supposed to be just a simple answer!

Art


Namaste', Art

Press any key to exit,
Press any other key to continue...
- unknown

274 views      
Thread locked
 

Messages in this Thread

 
94,426 Postings in 11,918 Threads, 348 registered users, 8 users online (0 registered, 8 guests)
Index | Admin contact |   Forum Time: Sep 22, 2019 - 12:03 pm EDT  |  Hits:28,656,166  (1,008 Today )
RSS Feed