Skip to content

Instantly share code, notes, and snippets.

@larryzhao
Created July 4, 2012 06:11
Show Gist options
  • Save larryzhao/3045668 to your computer and use it in GitHub Desktop.
Save larryzhao/3045668 to your computer and use it in GitHub Desktop.
Twitter::Autolink breaks in jruby when text contains Chinese or Japanese
# encoding: utf-8
require 'twitter-text'
options = { :username_include_symbol => true }
text = "@baozi hi you are a dog #dog"
text_cn = "@baozi 嗨你是一条狗诶 #狗狗"
text_jp = "@baozi ねえ、あなたは犬だ #犬"
puts "=== original ==="
puts text
puts text_cn
puts text_jp
puts "=== autolinked ==="
puts Twitter::Autolink.auto_link(text, options)
puts Twitter::Autolink.auto_link(text_cn, options)
puts Twitter::Autolink.auto_link(text_jp, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment