I must generate files for windows batch scripting, modifying template files, es.

dataIn = Import["template.bat","Lines"];
dataOut = aFunction[dataIn];

The problem comes from the box drawing characters (see https://en.wikipedia.org/wiki/Box-drawing_character ) in template.bat, because they are never diplayed rightly.

I have tried:

test[dataIn_, encoding_] := Export[
   encoding <> ".bat",
   StringJoin @ FromCharacterCode[
      ], encoding
dataIn = Import["template.bat", "Text"];
test[dataIn, #] & /@ $CharacterEncodings;

but none of generated files works. How can I handle them ?

  • $\begingroup$ As seen from StringJoin@FromCharacterCode[ToCharacterCode[Characters[dataIn]], #] & /@ $CharacterEncodings, several of the encodings aren't able to represents the box-drawing symbols. I tried the code, and the generated files do look right, except those that aren't able to represent the box-drawing symbols. Are you saving your template.bat file as UTF-8? $\endgroup$ – WeavingBird1917 Jun 15 '19 at 3:05
  • $\begingroup$ Hi ! No, I was working on template.bat saved as ANSI. But now I'm testing the UTF-8 options. What's the operating system on your computer ? $\endgroup$ – YoungStellarObject Jun 15 '19 at 20:29
  • $\begingroup$ My operating system is Windows 10. I saved the template.bat as a UTF-8 file; box drawing symbols doesn't show if saved as ANSI. $\endgroup$ – WeavingBird1917 Jun 16 '19 at 2:16
  • $\begingroup$ My operating system is Windows XP, I'm migrating to Windows 10. Now I have tried template.bat saved as "template - ansi.bat", "template - utf8 whitput BOM.bat", "template - utf8.bat" but box drawing characters never are seen correctly when runnig generated files. Would you receive the involved files? Can I send them here or should I use dropbox, or similar site? $\endgroup$ – YoungStellarObject Jun 16 '19 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.