晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby18/lib64/ruby/1.8/ |
| Current File : //opt/alt/ruby18/lib64/ruby/1.8/base64.rb |
#
# = base64.rb: methods for base64-encoding and -decoding stings
#
# Author:: Yukihiro Matsumoto
# Documentation:: Dave Thomas and Gavin Sinclair
#
# Until Ruby 1.8.1, these methods were defined at the top-level. Now
# they are in the Base64 module but included in the top-level, where
# their usage is deprecated.
#
# See Base64 for documentation.
#
require "kconv"
# The Base64 module provides for the encoding (#encode64) and decoding
# (#decode64) of binary data using a Base64 representation.
#
# The following particular features are also provided:
# - encode into lines of a given length (#b64encode)
# - decode the special format specified in RFC2047 for the
# representation of email headers (decode_b)
#
# == Example
#
# A simple encoding and decoding.
#
# require "base64"
#
# enc = Base64.encode64('Send reinforcements')
# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
# plain = Base64.decode64(enc)
# # -> "Send reinforcements"
#
# The purpose of using base64 to encode data is that it translates any
# binary data into purely printable characters. It is specified in
# RFC 2045 (http://www.faqs.org/rfcs/rfc2045.html).
module Base64
module_function
# Returns the Base64-decoded version of +str+.
#
# require 'base64'
# str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
# 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
# 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
# puts Base64.decode64(str)
#
# <i>Generates:</i>
#
# This is line one
# This is line two
# This is line three
# And so on...
def decode64(str)
str.unpack("m")[0]
end
# Decodes text formatted using a subset of RFC2047 (the one used for
# mime-encoding mail headers).
#
# Only supports an encoding type of 'b' (base 64), and only supports
# the character sets ISO-2022-JP and SHIFT_JIS (so the only two
# encoded word sequences recognized are <tt>=?ISO-2022-JP?B?...=</tt> and
# <tt>=?SHIFT_JIS?B?...=</tt>). Recognition of these sequences is case
# insensitive.
def decode_b(str)
str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
decode64($1)
}
str = Kconv::toeuc(str)
str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
decode64($1)
}
str = Kconv::toeuc(str)
str.gsub!(/\n/, ' ')
str.gsub!(/\0/, '')
str
end
# Returns the Base64-encoded version of +str+.
#
# require 'base64'
# Base64.b64encode("Now is the time for all good coders\nto learn Ruby")
#
# <i>Generates:</i>
#
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
# UnVieQ==
def encode64(bin)
[bin].pack("m")
end
# _Prints_ the Base64 encoded version of +bin+ (a +String+) in lines of
# +len+ (default 60) characters.
#
# require 'base64'
# data = "Now is the time for all good coders\nto learn Ruby"
# Base64.b64encode(data)
#
# <i>Generates:</i>
#
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
# UnVieQ==
def b64encode(bin, len = 60)
encode64(bin).scan(/.{1,#{len}}/) do
print $&, "\n"
end
end
module Deprecated # :nodoc:
include Base64
for m in Base64.private_instance_methods(false)
module_eval %{
def #{m}(*args)
warn("\#{caller(1)[0]}: #{m} is deprecated; use Base64.#{m} instead")
super
end
}
end
end
end
include Base64::Deprecated
|