Quantcast
Channel: Active questions tagged charset - Stack Overflow
Viewing all articles
Browse latest Browse all 59

Creating a file with a "Mac OS Central European" charset

$
0
0

i've been using javascript lately to modify data in files called "ALE" which is kind of a metadata table for video files. I'm not a professional programmer and I'm kind of stuck with a problem concerning the charset. I found some hints during research but unfortunately still haven't been able to solve the issue on my own.

My script is reading a file which already has the right charset, changes some data and creates a new file, but the texts end up messy due to broken special characters in the editing software after import. (Which isn't the case if I import the unaltered ale file without using my script)

I had some troubles with troubleshooting as I didn't find a way yet to really "see" the charset of those files. Visual Studio Code, Notepad++ and so on show UTF-8 even on the original ones. (I am working on Windows)So the only way to "debug" was to import the file in the editing software and see if the special characters are broken or not.From a chat with a support guy about a different topic I got the info that the charset has to be "Mac OS Central European" to be working correctly.I tried "cp10029" as well which seems the be an alias for the same charset. But both ways didn't solve the problem.https://en.wikipedia.org/wiki/Mac_OS_Central_European_encoding

After all I'm not sure if there is something wrong with my code, if the charset is not supported (i read about iconv-light, but didn't get it to work as i am using webpack and it seems to mess up the compiler due to the require) or if something else is happening.

Maybe someone has an idea how to further approach this?

This is how i import the file into the script

            let file = this.files[0];            let filename = file.name.split('.')                                    .slice(0, -1)                                    .join(".");            let fr = new FileReader();            fr.readAsText(file);            fr.onload = function(){                editAle(fr.result,filename)            }

This is how i create the new file for download."data" is the modified string of the original content.

            let filename = prefix +"_Edited.ale";            let element = document.createElement('a');            element.setAttribute('href', 'data:text/plain;charset='+ charset +','+ encodeURIComponent(data));            element.setAttribute('download', filename);            element.style.display = 'none';            document.body.appendChild(element);            element.click();            document.body.removeChild(element);

Thanks in advance for your time and concern,

Rob


Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>