Re: PyYAML multi-line strings
Joe Abbate <jma-ICVE9uepxrQgpMukQH3QewC/[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
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