Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perl, DOS and encodings

by Anonymous Monk
on Apr 29, 2020 at 23:43 UTC ( [id://11116251]=note: print w/replies, xml ) Need Help??


in reply to Perl, DOS and encodings

This command in bash works fine (Perl 5.30 shipped with Cygwin): git-md-toc -ut "some-text-in-russian" -Tutf8 "utf8-cyrillic.md" But it fails in DOS sessions -- the title is being added in wrong enco +ding. To resolve the issue I have to use one more option (standalone +StrawberryPerl 5.30):

Its simple, avoid "dos sessions", use perl

#!/usr/bin/perl -- use strict; use warnings; use utf8; system $^X, q{-e}, q{ use strict; use warnings; use Encode; use Data::Dump; my @argv = map{ decode('UTF-8', $_, Encode::FB_CROAK) } @ARGV; dd\@argv; }, qq{\x{43A}\x{435}\x{431}\x{430}\x{431}}, # kebab # copy from html below cause perlmonks doesnt utf, so browser converts + html entities 'кебаб', ;

As you can see from dd output below, кебаб is кебаб

Since perlmonks doesnt utf8 the browser converts to entities кебаб

[ "\x{43A}\x{435}\x{431}\x{430}\x{431}", "\x{43A}\x{435}\x{431}\x{430}\x{431}", ]

Why avoid dos sessions, at least unicode ones? Because its complicated. At one time I had a handle on this knowledge but long before that decided its simpler/more portable to avoid unicode in filenames and shells

How Command Line Parameters Are Parsed by David Deley

Quotes, Escape Characters, Delimiters - Windows CMD - SS64.com

Re: Non asci character and system call

Re^4: How can I get a Unicode @ARGV?

How can I get a Unicode @ARGV?

windows - How to make Unicode charset in cmd.exe by default? - Stack Overflow

Re^2: Windows 7: fork in perl script spawns new cmd window

Re: Parsing Windows CommandLine from Perl

Re: eval NoOp on cmd.exe line expr

Discipulus library

chcp can't do everything - Sorting it all Out - Site Home - MSDN Blogs

http://stackoverflow.com/questions/10764920/utf-16-on-cmd-exe

http://stackoverflow.com/questions/2182568/batch-script-is-not-executed-if-chcp-was-called

ConEmu - Handy Console Window download

Re: Perl in Windows - STDOUT to file Behavior difference by run context

Re^5: Out of date over <> and 5.10 (reproduce)

redirection problem

Win7, ASSOCiation , and @ARGV

Upside Down Text Revised

Windows console mangles UTF8 output

Re: Unicode again, in Win7 cmd (chcp 65001)

chcp can't do everything

chcp can't do everything - Sorting it all Out - Site Home - MSDN Blogs

https://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html

Replies are listed 'Best First'.
Re^2: Perl, DOS and encodings
by siberia-man (Friar) on Apr 30, 2020 at 07:28 UTC
    Thank you for sharing a lot of links. I will read them later.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116251]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2024-03-28 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found