Skip to content
This repository

ISO 3166 Output UTF-8 Encoding #22

Closed
wants to merge 1 commit into from

2 participants

Chris Farrar Robert Picard
Chris Farrar

Modified the scripts so that the output file of this fathead would be encoded as utf-8.

Robert Picard
rpicard commented

Thanks for updating the script. I'm working on integrating this.

Robert Picard

I'm going to go ahead and close this request. The plugin is live now.

Robert Picard rpicard closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 22, 2012
Chris Farrar cjfarrar Changed coding of output file to utf-8 82d0fae
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. +11 11 iso_3166_codes/parse.py
22 iso_3166_codes/parse.py
... ... @@ -1,11 +1,11 @@
1 1 #!/usr/bin/python
2   -# -*- coding: utf-8 -*-
3 2
4 3 # Released under the GPL v2 license
5 4 # https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6 5
7 6 import lxml.etree, lxml.html
8 7 import re
  8 +import codecs
9 9
10 10 url = "http://www.iso.org/iso/list-en1-semic-3.txt"
11 11 title = "ISO 3166 Country Codes"
@@ -20,26 +20,26 @@
20 20 #Read and throw out first line
21 21 input_file.readline()
22 22
23   -output_file = open( outp, "w")
  23 +output_file = codecs.open( outp, "w", encoding="utf-8")
24 24
25 25 #Loop thru the remainder of the file, format each line
26 26 #and print it to the output file.
27 27 for line in input_file.readlines() :
28   - line = line.strip();
29   - pair = line.split( ';' );
  28 + line = line.strip()
  29 + pair = line.split( ';' )
30 30 if len( pair ) < 2 :
31 31 continue;
32   - output_file.write( "\t".join ( [ pair[ 1 ],
  32 + output_file.write( "\t".join ( [ pair[ 1 ],
33 33 "",
34 34 url,
35   - pair[ 0 ],
  35 + pair[0],
36 36 "",
37 37 "",
38 38 "",
39   - "" ] )
40   - );
41   - output_file.write( "\n" );
  39 + "" ] ).decode('latin-1')
  40 + )
  41 + output_file.write( "\n" )
42 42
43   -input_file.close();
44   -output_file.close();
  43 +input_file.close()
  44 +output_file.close()
45 45

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.