Hello ikegami,
thanks very much for a fast response!
I ran the first of your scripts (without 'use utf8;') in a PowerShell console with code page 850 in Strawberry Perl 5.32.1 32-bit.
Without redirection I get the same output as you.
With redirection however I get this file content:
000000 ff fe 1c 25 f1 00 1c 25 c2 00 1c 25 5d 25 1c 25
000010 e4 00 1c 25 fb 00 1c 25 a3 00 1c 25 92 01 0d 00
000020 0a 00
This is windows 10 version 21H2 (Build 19044.3086).
That made me curious, and I repeated the run in a plain CMD.EXE shell.
And surprise! I then get the same output as you did.
So something in PowerShell disturbs the output during redirection, it seems. That nasty behavior took me by surprise. It looks like that is where I get the unwanted extra UTF-16 LE BOM conversion from...
Another thing I noticed with PowerShell was that
perl "-Mv5.14" -ne"say sprintf '%vX', $_" a did only produce two empty lines.
Thanks very much again for helping me out!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.