def to_pinyin(s, delimiter='<STR_LIT:U+0020>', all_readings=False, container='<STR_LIT>',<EOL>accented=True):
hanzi = s<EOL>pinyin = '<STR_LIT>'<EOL>while hanzi:<EOL><INDENT>match = re.search('<STR_LIT>' % (delimiter, zhon.hanzi.punctuation),<EOL>hanzi)<EOL>if match is None and hanzi:<EOL><INDENT>pinyin += hanzi<EOL>break<EOL><DEDENT>match_start, match_end = match.span()<EOL>if match_start > <NUM_LIT:0>:<EOL><INDENT>pinyin += hanzi[<NUM_LIT:0>:match_start]<EOL><DEDENT>readings = _hanzi_to_pinyin(match.group())<EOL>if match.group() in _WORDS:<EOL><INDENT>if all_readings:<EOL><INDENT>reading = _enclose_readings(container,<EOL>_READING_SEPARATOR.join(readings))<EOL><DEDENT>else:<EOL><INDENT>reading = readings[<NUM_LIT:0>]<EOL><DEDENT>pinyin += reading<EOL><DEDENT>else:<EOL><INDENT>for character in readings:<EOL><INDENT>if isinstance(character, str):<EOL><INDENT>pinyin += character<EOL><DEDENT>elif isinstance(character, list) and all_readings:<EOL><INDENT>pinyin += _enclose_readings(<EOL>container, _READING_SEPARATOR.join(character))<EOL><DEDENT>elif isinstance(character, list) and not all_readings:<EOL><INDENT>if (pinyin and character[<NUM_LIT:0>][<NUM_LIT:0>] in zhon.pinyin.vowels and<EOL>pinyin[-<NUM_LIT:1>] in zhon.pinyin.lowercase):<EOL><INDENT>pinyin += "<STR_LIT:'>"<EOL><DEDENT>pinyin += character[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>hanzi = hanzi[match_end:]<EOL><DEDENT>if accented:<EOL><INDENT>return pinyin<EOL><DEDENT>else:<EOL><INDENT>return accented_to_numbered(pinyin)<EOL><DEDENT>
Convert a string's Chinese characters to Pinyin readings.

    *s* is a string containing Chinese characters. *accented* is a
    boolean value indicating whether to return accented or numbered Pinyin
    readings.

    *delimiter* is the character used to indicate word boundaries in *s*.
    This is used to differentiate between words and characters so that a more
    accurate reading can be returned.

    *all_readings* is a boolean value indicating whether or not to return all
    possible readings in the case of words/characters that have multiple
    readings. *container* is a two character string that is used to
    enclose words/characters if *all_readings* is ``True``. The default
    ``'[]'`` is used like this: ``'[READING1/READING2]'``.

    Characters not recognized as Chinese are left untouched.