Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
XSL = <<-EOXSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="ISO-8859-1"/>
<xsl:param name="indent-increment" select="' '"/>
<xsl:template name="newline">
@pasela
pasela / unicodeescape.vim
Created December 17, 2011 19:30
Escape/Unescape unicode string.
" unicodeescape.vim - Escape/Unescape unicode string.
function! UnicodeEscapeString(str)
let oldenc = &encoding
set encoding=utf-8
let escaped = substitute(a:str, '[^[:alnum:][:blank:][:cntrl:][:graph:]]', '\=printf("\\u%04x", char2nr(submatch(0)))', 'g')
let &encoding = oldenc
return escaped
endfunction