Attachment 'vimcolor-utf8.patch'

Download

   1 --- vimcolor.py.orig	2004-10-25 01:07:42.000000000 -0500
   2 +++ vimcolor.py	2006-11-09 11:44:50.000000000 -0600
   3 @@ -175,23 +175,25 @@
   4  			self.syntaxmap.update(syntaxmap)
   5  
   6  	def _build_syntax(self, filepath, filetype=None):
   7 -		import os, tempfile
   8 +		import os, tempfile, codecs
   9  		self.syntax=[]
  10  		vstemp=tempfile.mktemp('.vim','mark')
  11 -		open(vstemp,'w').write(VIM_MARK_RC)
  12 +		codecs.open(vstemp,'w','utf-8').write(VIM_MARK_RC)
  13  		if not os.path.exists(filepath):
  14  			raise IOError('File "%s" not found'%(filepath))
  15  		# tempfile to save
  16  		outtemp=tempfile.mktemp('.xml')
  17  		# make vim script
  18  		shtemp=tempfile.mktemp('.vim')
  19 -		sh=open(shtemp,'w')
  20 +		sh=codecs.open(shtemp,'w', 'utf-8')
  21  		if filetype:
  22  			filetype=':set filetype=%s\n'%(filetype,)
  23  		else:
  24  			filetype=''
  25  		sh.write(''':filetype on
  26 -%(filetype)s:source %(vstemp)s
  27 +%(filetype)s:set encoding=utf-8
  28 +:source %(vstemp)s
  29 +:set fileencoding=utf-8
  30  :write! %(outtemp)s
  31  :qall!
  32  '''%{'filetype': filetype,
  33 @@ -201,7 +203,7 @@
  34  		# run colorize
  35  		os.system("%s %s %s -s %s >/dev/null 2>&1"%(VIM_COMMAND, VIM_OPTIONS, filepath, shtemp))
  36  		# load stuff and kill files
  37 -		lines=open(outtemp,'r').readlines()
  38 +		lines=codecs.open(outtemp,'r', 'utf-8').readlines()
  39  		try:
  40  			os.unlink(shtemp)
  41  		except:
  42 @@ -260,8 +262,9 @@
  43  
  44  	def markString(self, string, extension='.dat', filetype=None):
  45  		import tempfile
  46 +		import codecs
  47  		fn=tempfile.mktemp(extension)
  48 -		f=open(fn,'w')
  49 +		f=codecs.open(fn,'w','utf-8')
  50  		f.write(string)
  51  		f.close()
  52  		res=self._mark(fn, filetype)
  53 @@ -339,11 +342,14 @@
  54  
  55  if __name__=='__main__':
  56  	import sys
  57 +	import codecs
  58 +	import traceback
  59  	if len(sys.argv)>1:
  60  		try:
  61 -			data=open(sys.argv[1],'r').read()
  62 +			data=codecs.open(sys.argv[1],'r','utf-8').read()
  63  		except:
  64  			sys.stderr.write("can't read %s\n"%(sys.argv[1]))
  65 +			traceback.print_exc()
  66  			sys.exit(1)
  67  	else:
  68  		data=TEST

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-08-19 14:02:49, 8.9 KB) [[attachment:VimColor-iso8859_15.py]]
  • [get | view] (2004-10-25 06:07:42, 8.9 KB) [[attachment:VimColor.py]]
  • [get | view] (2005-11-25 08:14:41, 0.6 KB) [[attachment:vimcolor-utf8.diff]]
  • [get | view] (2006-11-09 17:54:21, 1.8 KB) [[attachment:vimcolor-utf8.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.