Fix bad encode symfony to cmd - cmd

when I try to introduce something the console with bin / console, for example:
php bin/console doctrine:generate:entity
The output of cmd returns these characters
How can i fix it?

What you see are ANSI color codes. Linux and OS X systems should support them natively.
But on Windows, you'll either need to use an emulated terminal like Cygwin or a Windows implementation of an ANSI capable terminal, like ANSICON to see the output as it was meant to be. Also see the note in the documentation about this for further alternatives/possibilities.

Related

Codeception bash color output does not display

I have been testing with Codeception and PhantomJS for a while, but when ever i have to debug and run
vendor/bin/codecept run --debug
with colors set to true all i get is:
Modules: ←[33mWebDriver, AcceptanceHelper←[39m
and so on... So for some reason the color is just outputed in a raw format and is not working at all. Colors usually work. like when i use "ls --color" it just works.
My System is Windows 7 i'm using the "git bash" and i have also tried the regular "cmd" "powershell" and "cygqwin". Neither one of them seem to work with codeceoptions output.
So what is the problem? I'm clueless :(
in bash, try running
export TERM=ansi
or
export TERM=xterm
before running your program
or, to test color output from the shell itself:
echo -e "\e[41m\e[32mCOLOR\e[0m"
if that does work than it is the program, not the environment
finally, you might just need a better console.
try conemu, it has excellent ansi color support and i use it for cmd powershell bash perl and ssh sessions :)
http://sourceforge.net/projects/conemu/
Your application (Codeception) was not adapted to Windows console, which doesn't support ANSI colorizing. To enable ANSI colors you may choose one of the following options:
ConEmu is the Windows local terminal with ANSI capabilities and many other features like tabs, splits, preconfigured shell tasks, ... Also, it's the only terminal which able to "replace" default Windows console. Yep, I'm the author.
Some applications may work properly in mintty (bundled with cygwin or msys). Many native Windows console tools can't work properly in this terminal, but may be your app will be fine.
There is AnsiCon project. It enables ANSI colorizing in standard Windows console.
BTW, bash's ls (cygwin or msys) was adapted to Windows console API, so it doesn't post ANSI to terminal, unless terminal has done special initialization of POSIX subsystem. ConEmu can do this initialization via cygwin/msys connector.

How to disable stdin echo in windows console

I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin).
However, it's needed that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses"
This problem in Ruby over linux, can be solved using the "stty" linux command:
%x{stty -icanon -echo}
because it is the linux terminal who automatically outputs the user-keys into the terminal, so running the "stty" command tells the terminal to stop showing the user-key-presses.
But my program must run in windows, so I tried searching for a "stty" equivalent command for windows console, but still found nip...
?any suggestions, pointers ?
Look at Highline gem. To clarify, look at ask method and provide a block to silence it's output. It is well exemplified in their documentation

Ruby IRB output is messed up in the console on Windows 7

I am getting very strange outputs from my IRB console. Here it is:
irb(main):001:0> File.dirname(__FILE__)
=> ←[0;31m"←[0;0m←[0;36m.←[0;0m←[0;31m"←[0;0m
Seems like an encoding issue, right? I am not sure why this is happening. Any ideas how to fix it?
Those are escape codes used to set colors in a terminal program; probably most popularly to colour a prompt in an xterm or compatible terminal. My bash prompt environment variable, for example, looks like this:
PS1="\[\033]2;\w\007\]\[\033[0;31m\]\u#\h \[\033[0;32m\]\!\[\033[0;31m\]> \[\033[0m\]
It looks like some string like that one is getting into your console and confusing it (since it's not bash and/or in an xterm-friendly terminal emulator, I guess).
As Carl and Mike pointed out, that's color information. You can have the colors actually show up if you install ANSICON. Wirble and Cucumber showed up with colored text in their output in a dos box on my Windows machine once I installed that.

How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?

This is related to this question : How to get coloured file listing in windows cmd shell ?
I'm trying to get, wouldn't you believe it, coloured file listing in windows cmd shell. Windows are XP SP2, if that matters.
In the old DOS days there used to be little programs like hdir, adir and such which displayed that nice. Nowadays, such programs are no more.
There is however, ls, from unixkit-tiny or unixtools. Unfortunatelly, it uses ANSI escape codes for displaying colours, and cmd doesn't handle those too well.
There are several solutions which include loading ansi.sys and command.com, but command.com doesn't handle long filenames that well, and is awfully slow. Even then sometimes it has problems displaying colours.
So what I'm asking, is there a way to get coloured file listing in windows cmd shell, apart from using cygwin ? Or is there a way to get ANSI escape codes to work with cmd.exe in a way so that native ls will play nicely ?
I ran across ANSICON at http://adoxa.110mb.com/ansicon/index.html ansicon github repo
Using it to colorize NAnt output. ls --color is being processed correctly.
Source code is provided, but I haven't examined it.
Actually I reckon A+ for ansicon -- Use
ansicon.exe -I
Installs it as a filter on your CMD.exe sessions. Works a treat with HTTY (ruby gem).
:-)
You could start the builtin Telnet server, firewall it to only allow localhost access, and use a telnet client that understands such escapes - even the native one. (I know, an ugly hack.)
It's possible to patch cmd.exe....
http://gynvael.coldwind.pl/?id=130&lang=en

Getting 256 colors out of ruby-ncurses

I've got 256 colors working great in my terminal (test scripts here), but it stops working when I use ncurses (via Ruby-ncurses). Printing the escape sequences given on that page works fine, but when I initialize ncurses 'puts' stops working and I can't output the colors with any of the various ncurses color changing/string output functions I've found. What gives?
I am not sure if this would be all the story, but make sure your terminal capabilities do indeed provide for the 256 colors description.
What is the TERM environment variable value? Try setting it to xterm-256color and rerun it.
ncurses should then get the proper color escape sequences.
You can also test the terminal capabilities and terminal color output with the program we use at SXEmacs development:
http://www.triatlantico.org/tmp/tty-colors.c
Compile with gcc -o tty-colors tty-colors.c -lncurses
EDIT:
Note that just because the scripts that are found on the net output the 256 colors, that is not "all set".
Curses programs rely on terminfo and termcap and the TERM environment variable to find out how to interact with the terminal.
So in order for a curses app to be able to use the 256 colors one should set the TERM variable to an existing terminal name which supports 256 colors.
The C program above will show you what ncurses thinks about your terminal, not just output the xterm sequences like most scripts do [even the one from X.org]
njsf: You were partially right here, and after tinkering a lot more I eventually got it to work. Thanks for your help. The story: XTerm (and rxvt, and Eterm) support 256 colors via escape sequences (what I was seeing) but 'tput colors' will say '8' and ncurses won't be able to get at them, because ncurses is playing nice and attempting to access via terminfo.
For the benefit of anyone with similar pain:
I found I need to install the ncurses-term (Ubuntu) package to get /lib/terminfo/x/xterm-256color and other 256-color terminfo files. Then I set my TERM to xterm-256color and added the line '*customization: -color' to my ~/.Xdefaults, ran 'xrdb -merge ~/.Xdefaults' to load it, and from then on I have proper 256 color support in new xterms.
setting
ENV['TERM'] += '-256color' if ENV['TERM'] == 'xterm' # activate 256 colors
works on ubuntu 10.04 +

Resources