To set the \uXXXX codes back to utf-8:

json_string.gsub!(/\\u([0-9a-z]{4})/) {|s| [$1.to_i(16)].pack("U")}




File.open("/mnt/shared/2015111016","r").each_line do |line|
next unless line =~ /forumDir/
a = line.split('forumDir')[1]
a = a.split('forumSecondDir')[0]
a = a.split('"')[2]
a = a[0...-1]
a = a.gsub('\\\\','\\')
puts a.gsub!(/\\u([0-9a-z]{4})/) {|s| [$1.to_i(16)].pack("U")}
end

猜你喜欢

转载自hhg08.iteye.com/blog/2256537