Re: Does pyparsing support UNICODE strings?

Discussion in 'Python' started by Robert Kern, Aug 4, 2005.

  1. Robert Kern

    Robert Kern Guest

    could ildg wrote:
    > pyparsing is very convenient to use. But I want to find some a py tool
    > to parse non-English strings. Does pyparsing support UNICODE strings?
    > If not, can someone tell me what py tool can do it? Thanks in advance.


    Try it!

    # vim:fileencoding=utf-8

    from pyparsing import Word

    text = "ΚαλημέÏα, κόσμε!".decode('utf-8')
    alphas = u''.join(unichr(x) for x in xrange(0x386, 0x3ce))

    greet = Word(alphas) + u',' + Word(alphas) + u'!'
    greeting = greet.parseString(text)
    print greeting

    --
    Robert Kern


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
     
    Robert Kern, Aug 4, 2005
    #1
    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. could ildg
    Replies:
    0
    Views:
    348
    could ildg
    Aug 4, 2005
  2. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    790
    Malcolm
    Jun 24, 2006
  3. Asterix
    Replies:
    5
    Views:
    732
    Matt Nordhoff
    Aug 31, 2008
  4. RHaus

    Support for Unicode strings

    RHaus, Jan 11, 2006, in forum: Ruby
    Replies:
    1
    Views:
    103
    Austin Ziegler
    Jan 11, 2006
  5. fhscobey
    Replies:
    0
    Views:
    241
    fhscobey
    Nov 3, 2005
Loading...

Share This Page