Mis-coded Chinese filenames

I frequently run in to Windows filenames that are wrongly being displayed as if they were in CP437/OEM when the actual encoding is GB2312.

I’d like to use 010 Editor to make Windows treat such a filename as GB2312.

I’ve used 010 Editor’s ConvertString function before. Could an 010 script be written to use that for my purpose, and then be able to run the script from the Explorer right-click menu or using a Windows command line?

You should be able to do this in 010 Editor and there are a few different ways. You could make a simple script something like:

string filename = GetFileName();
string newFilename = ConvertString( filename, CHARSET_OEM, CHARSET_CHINESE_S );
FileSave( newFilename );
FileClose();

and then run 010 Editor from the command line with:

010editor FileToConvert.dat -script:ConvertFilename.1sc

You could also use the FindFiles function in your script to loop through and process all files in a certain directory. You may have to do some other conversions related to UTF-8 in the script but it’s hard to say without seeing a sample of what needs to be converted. Let us know if you can’t get it to work.

Graeme
SweetScape Software

1 Like