MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - python -c text not correct
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

python -c text not correct

 Post Reply Post Reply
Author
Message Reverse Sort Order
ForumDBA View Drop Down
Admin Group
Admin Group


Joined: 10.Mar.2008
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote ForumDBA Quote  Post ReplyReply Direct Link To This Post Topic: python -c text not correct
    Posted: 18.Sep.2019 at 16:22
The python command isn't using the expected encoding for a command-line command, hence why MetaEdit+ shows an error (it shouldn't actually crash though - it just shows the error and you can press Terminate).

See if there are any options in python to change the encoding to match the command line's Unicode "cmd /u" (UCS-2 le). E.g. https://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python. If you can't figure it out on the Python side of things, you can simply have python write to a file with external...executeBlocking and then MetaEdit+ can read the file, specifying the encoding if necessary.
Back to Top
edward22243 View Drop Down
Member
Member
Avatar

Joined: 19.Apr.2019
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote edward22243 Quote  Post ReplyReply Direct Link To This Post Posted: 18.Sep.2019 at 14:09
Goal was to generate a timestamp as such:

external 'python -c "from datetime import datetime; n = datetime.now(); print(n.strftime(''%d-%b-%H-%M-%S''));"' read 

and that also crashed, hence the investigation.
Back to Top
edward22243 View Drop Down
Member
Member
Avatar

Joined: 19.Apr.2019
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote edward22243 Quote  Post ReplyReply Direct Link To This Post Posted: 18.Sep.2019 at 14:07
This is my generator code:

$str = 'python -c "print(''a'');"'
$e = __(external $str read)

It is self-explanatory Smile
The result is that the program crashes: "Unhandled exceptions: Strings only store Characters"

For some other text than a, I get for $e a string of some Chinese signs. 

How to continue?


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.16
Copyright ©2001-2013 Web Wiz Ltd.

This page was generated in 0.047 seconds.