Opening & writing to UTF-8 files; copyright symbol again -- solution
[email protected] ("Highsmith, Anne L") Fri, 13 Nov 2015 22:05:01 +0000
| Newsgroups | perl.perl4lib |
|---|---|
| Message-ID | <[email protected]> |
--_000_cddafd5c79b648a6bdc6b460982d2e56exch2pmbxt4adstamuedu_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I should probably say, "apparent solution" 'cause character set issues neve= r seem to end. However, combining Jon Gorman's recommendation with some Googling, I get: my $outfile=3D'4788022.edited.bib'; open (my $output_marc, '>', $outfile) or die "Couldn't open file $!" ; binmode($output_marc, ':utf8'); The open statement may not be quite correct, as I am not familiar with the = more current techniques for opening file handles that John mentioned. Howev= er, when I use those instructions to open the output file rather than what = I had before, the copyright symbol does indeed come across as C2 A9 as it w= as in the original record. I didn't want to use the utf8, because I've trie= d that before and ended up with double-encoding (and a real mess). But I'll= continue testing. The results of the googling I referred to can be found at: https://groups.g= oogle.com/forum/#!topic/perl.perl4lib/sy7hqiBQ1yM Anne L. Highsmith Director, Consortia Systems TAMU Libraries 5000 TAMU College Station, TX 77843-5000 979 862 4234 [email protected] --_000_cddafd5c79b648a6bdc6b460982d2e56exch2pmbxt4adstamuedu_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= //www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"= > <meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:#0563C1; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:#954F72; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:"Calibri",sans-serif; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri",sans-serif;} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72"> <div class=3D"WordSection1"> <p class=3D"MsoNormal">I should probably say, “apparent solution̶= 1; ‘cause character set issues never seem to end. <o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">However, combining Jon Gorman’s recommendation= with some Googling, I get:<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Courier New"">= my $outfile=3D'4788022.edited.bib';<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Courier New"">= open (my $output_marc, '>', $outfile) or die "Couldn't open file $!= " ;<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Courier New"">= binmode($output_marc, ':utf8');<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-family:"Courier New"">= <o:p> </o:p></span></p> <p class=3D"MsoNormal">The open statement may not be quite correct, as I am= not familiar with the more current techniques for opening file handles tha= t John mentioned. However, when I use those instructions to open the output= file rather than what I had before, the copyright symbol does indeed come across as C2 A9 as it was in the ori= ginal record. I didn’t want to use the utf8, because I’ve tried= that before and ended up with double-encoding (and a real mess). But IR= 17;ll continue testing.<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">The results of the googling I referred to can be fou= nd at: <a href=3D"https://groups.google.com/forum/#!topic/perl.perl4lib/sy7= hqiBQ1yM"> https://groups.google.com/forum/#!topic/perl.perl4lib/sy7hqiBQ1yM</a><o:p><= /o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Anne L. Highsmith<o:p></o:p></p> <p class=3D"MsoNormal">Director, Consortia Systems<o:p></o:p></p> <p class=3D"MsoNormal">TAMU Libraries<o:p></o:p></p> <p class=3D"MsoNormal">5000 TAMU<o:p></o:p></p> <p class=3D"MsoNormal">College Station, TX 77843-5000<o:p></o:p= ></p> <p class=3D"MsoNormal">979 862 4234<o:p></o:p></p> <p class=3D"MsoNormal">[email protected]<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> </body> </html> --_000_cddafd5c79b648a6bdc6b460982d2e56exch2pmbxt4adstamuedu_--