There are other posts similar to this, but I've not been able to find a solution.
I'm trying to receive a utf8 encoded string from a perl program to a C# application, but I always get the ANSI string. The perl's print command does show the correctly encoded output, but when using the system call the output is ANSI. This works in linux, but not Windows.
If I run Example.exe "Ħis. Ŧ good" it works correctly displaying the utf8 string.
However, running the perl program does not work. Please advise.
Here are sample programs.
To see the correct utf8 encoding in the Windows console you have to first change the active code page with the
chcp 65001 command.
#!/usr/bin/perl -w
use strict;
use utf8;
binmode(STDOUT,':encoding(UTF-8)');
my $string= "\x{126}is. \x{166}good";
#my $string = pack('U', 294) . "is. " . pack('U', 358) . " good";
print "Sent = $string\n";
system ("Example.exe \"$string\"");
C# app.
using System;
using System.Text;
namespace Example
{
class Example
{
static void Main(string[] args)
{
Console.WriteLine("Received " + args[0]);
System.Environment.Exit(0);
}
}
}
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.