How do you check the utf8 flag on a given string?

Discussion in 'Perl Misc' started by ~greg, May 2, 2005.

  1. ~greg

    ~greg Guest

    One case of the problem I'm having is that I'm reading from a file strings
    containing Ns with tildes on them
    Ñ
    (- or they're something, anyway, that I know should look like
    a ascii 209 --in 8859-1 (I guess) )

    And I'm trying to sort strings so that these get sorted like 'n's.

    At the moment I'm trying to do this by checking for ordinals 209
    and then converting them to 'n's for the comparisons.

    I'm also checking, eg, for ordinals 195 ( 'A's with a tildes on them, - Ã )

    Problem is that the 'n's are getting sorted as if they were 'a's.

    And the Ñ (--N with tilde) get printed to an HTML file as Ã'
    ( ---A with tilde followed by a back-tick)
    -- which does appear in the rendered HTM as an Ñ (N with tilde).

    OBVIOUSLY - I don't don't know what I'm doing!

    It seems to me that the sorting is being done on bytes,
    whereas it should be being done on utf8-wide characters.

    So I think the first step for me would be to check the utf8-flags
    of the program's strings at each point in the processing,
    to see how the program is regarding them.

    But I don't know how to check that.

    ~greg
     
    ~greg, May 2, 2005
    #1
    1. Advertising

  2. ~greg

    Guest

    Re: How do you check the utf8 flag on a given string?

    ~greg wrote:

    > Subject: How do you check the utf8 flag on a given string?


    utf8::is_utf8
     
    , May 2, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    599
    Thomas Weidenfeller
    Apr 19, 2006
  2. chiara
    Replies:
    6
    Views:
    501
    Barry Schwarz
    Oct 6, 2005
  3. 2Barter.net
    Replies:
    0
    Views:
    395
    2Barter.net
    Dec 13, 2006
  4. Casey Hawthorne
    Replies:
    385
    Views:
    6,032
    ng2010
    Apr 4, 2010
  5. gry
    Replies:
    2
    Views:
    822
    Alf P. Steinbach
    Mar 13, 2012
Loading...

Share This Page