Could you clarify a few things?

it's also fine on the Windows system if the output filehandle is to a file, or if I redirect the output to a file (rather than allowing it to go to the cmd.exe console)

In both of those cases, what encoding is the resulting file in? (see for example my tool enctool)

use utf8; ... unsigned char a = '±';

That looks wrong to me because a char is one byte and you've given it two (C2 B1), so I don't know if your C example is representative, and gcc does complain warning: multi-character character constant [-Wmultichar].

In pure Perl, with a combination of chcp 65001 and use open qw/:std :encoding(UTF-8)/;, I can get it to output correctly, but I guess the question is what encoding the library is using (hence my question above).

C:\Temp>type test.pl
#!perl
use warnings;
use strict;
use open qw/:std :encoding(UTF-8)/;

print "\N{U+B1}\N{U+221E}\n";

C:\Temp>chcp
Active Codepage: 850.

C:\Temp>perl test.pl
┬▒Ôê×

C:\Temp>chcp 65001
Active Codepage: 65001.

C:\Temp>perl test.pl
±∞

In reply to Re: Encoding problem with function in C library by haukex
in thread Encoding problem with function in C library by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.