Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special formatting characters rendered as text in Windows Powershell and CMD #68

Closed
FuSoftware opened this issue Aug 7, 2020 · 5 comments · Fixed by #80
Closed

Special formatting characters rendered as text in Windows Powershell and CMD #68

FuSoftware opened this issue Aug 7, 2020 · 5 comments · Fixed by #80
Labels
bug Something isn't working

Comments

@FuSoftware
Copy link

FuSoftware commented Aug 7, 2020

OS : Windows 10 using cmd.exe and powershell

Upon trying your tool, it seems like the character encoding used to, I guess, color the lines, or at least add some text encoding, produces strange characters when used on Powershell and Windows CMD.

I suppose these are the special chracters used for the color formatting. I'm curious if it's possible, in the source code, to do automatic terminal detections to disable them when not on a compatible terminal.

And yes, I know about the -r option, which I use, it's just that a Windows user not being aware of it might be surprised

hors "dart print text"
- Answer from https://stackoverflow.com/questions/21028751/how-do-i-print-to-the-console-with-dart
�[38;2;211;208;200mimport 'dart:html';
�[38;2;211;208;200m
�[38;2;211;208;200mmain() {
�[38;2;211;208;200m  var value = querySelector('input').value;
�[38;2;211;208;200m  print('The value of the input is: $value');
�[38;2;211;208;200m}
@FuSoftware FuSoftware changed the title Strange caracters prepended to returned code when used in Windows Powershell and CMD Special formatting characters rendered as text in Windows Powershell and CMD Aug 7, 2020
@WindSoilder
Copy link
Owner

Oh, hi. Very thanks for your report.

I'm sorry that I haven't make fully tests on powershell and cmd(due to the lacks of PC).

I will try to figure out how to deal with this in a better way :) There are 2 ways to handle this:

  1. fix the issue, make colorful output in powershell and CMD, or
  2. If I can hardly find a solution to colorize output in powershell and CMD, we can output the raw text by default on windows system as a temporary solution. (don't need to specify -r argument everytime).

@dzervas
Copy link
Contributor

dzervas commented Aug 8, 2020

I dunno if we can use a custom crate to colorize but this crate does that well: https://github.com/BurntSushi/termcolor

@FuSoftware
Copy link
Author

I'll take a look this week, since I have both PS and CMD at hand. For now there's always the -r option, so it's not a big issue. But since I saw the so crate supports PS color formatting, I'm sure there's a way

@WindSoilder WindSoilder added the bug Something isn't working label Aug 10, 2020
@WindSoilder
Copy link
Owner

@FuSoftware You can try to make use of windows terminal which support colorize feature.

For powershell and cmd, I need to check for a while :-)

@WindSoilder
Copy link
Owner

WindSoilder commented Aug 16, 2020

Hi, Windows Powershell and CMD highlight feature should be ok for now(v0.6.8) :-) Feel free to have a look.
图片

And please note that hors can't highlight dart lang, so the output will be the same to hors dart print text -r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants