Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks

I know Tk is not capable of showinf all Unicode charachters. That's okay for me. hat I want to avoid is that my GUI doesn't break if a string contains a unicode character which is not supported. This is a working example:

.
use strict; use warnings; use utf8; use Tk; my $mw = MainWindow->new; my $text = "🙂"; $mw->Label(-text => $text)->pack; MainLoop;

If I would know all unsupported characters I could perform a substitution and delete them... but I don't know them. In $text I'd like to have only supported characters. Any idea?

Replies are listed 'Best First'.
Re: Tk UCS-2LE:code point too high
by Kordaff (Scribe) on Jun 30, 2016 at 22:45 UTC
    You might try this instead:
    my $text="\x{1F642}";
    Using the hex version of the decimal value 128578 does seem to work.
    --
    Kordaff

      I tried with several Perl versions and both values break the GUI

        I tried with several Perl versions and both values break the GUI

        Applying Kordaff's suggestion to your code works perfectly for me. ie.

        #!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new; my $text = "\x{1F642}"; $mw->Label(-text => $text)->pack; MainLoop;

        This produces a window with the smiley char. I'm using Tk 804.032 on perl 5.20.3.

Re: Tk UCS-2LE:code point too high
by kcott (Archbishop) on Jul 01, 2016 at 13:41 UTC