Re: PyYAML multi-line strings

Kirill Simonov <xi-RCSp1WnSyaseIZ0/[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
Hi Joe,

Sorry for a late reply.

Use yaml.dump(..., allow_unicode=True)

By default, pyyaml always escape non-ASCII characters, allow_unicode 
reverses this behavior.

Thanks,
Kirill

On 01/17/2013 03:11 PM, Joe Abbate wrote:
> Hello everyone,
>
> I haven't received a reply to the message below.  Maybe it was sent at
> an inopportune moment (everybody still celebrating)?  Anyway, the
> problem still remains.  I've tried using variations of yaml.dump(data,
> encoding=...) but under both Python 2 and 3 the result stays the same.
> I could report this as a PyYAML bug but if possible I'd prefer to get
> some feedback from the list first.
>
> Thanks,
>
> Joe
>
> On 02/01/13 15:32, Joe Abbate wrote:
>> I have a slightly different problem, reported by someone who is using
>> Spanish accented characters.  The data is stored in a UTF-8 encoded
>> Postgres database and fetched into Python.  Under Python2, this caused
>> an infamous UnicodeError: ascii codec can't encode.  Under Python3,
>> there was no error but the string wasn't shown in block style.
>>
>> So I now decode the string from utf_8 into unicode under Python2 and use
>> a class the expects Python2 'unicode' class.  Now the behavior under
>> Python2 is the same as Python3: no error but no block style either.
>>
>> Here is some sample output, one with an accent, the other without:
>>
>>    view tfilm:
>>      definition: " SELECT film.film_id, film.title,\n        CASE\n
>>        WHEN\
>>        \ film.description IS NULL THEN 'Jur\xEDdico'::text\n
>> ELSE film.description\n\
>>        \        END AS description\n   FROM film;"
>>    view tfilm_noaccent:
>>      definition: |2-
>>         SELECT film.film_id, film.title,
>>                CASE
>>                    WHEN film.description IS NULL THEN 'Juridico'::text
>>                    ELSE film.description
>>                END AS description
>>           FROM film;
>>
>> Is the problem because pyyaml can't handle the \xED embedded in the
>> string or is it something else?  If the former, is there some workaround?
>>
>> Happy 2013!
>>
>> Joe
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> _______________________________________________
> Yaml-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core
>


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.