$25 GRAYBYTE WORDPRESS FILE MANAGER $62

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby21/lib64/ruby/2.1.0/

HOME
Current File : /opt/alt/ruby21/lib64/ruby/2.1.0//kconv.rb
#
# kconv.rb - Kanji Converter.
#
# $Id: kconv.rb 30112 2010-12-07 11:47:39Z naruse $
#
# ----
#
# kconv.rb implements the Kconv class for Kanji Converter.  Additionally,
# some methods in String classes are added to allow easy conversion.
#

require 'nkf'

#
# Kanji Converter for Ruby.
#
module Kconv
  #
  # Public Constants
  #

  #Constant of Encoding

  # Auto-Detect
  AUTO = NKF::AUTO
  # ISO-2022-JP
  JIS = NKF::JIS
  # EUC-JP
  EUC = NKF::EUC
  # Shift_JIS
  SJIS = NKF::SJIS
  # BINARY
  BINARY = NKF::BINARY
  # NOCONV
  NOCONV = NKF::NOCONV
  # ASCII
  ASCII = NKF::ASCII
  # UTF-8
  UTF8 = NKF::UTF8
  # UTF-16
  UTF16 = NKF::UTF16
  # UTF-32
  UTF32 = NKF::UTF32
  # UNKNOWN
  UNKNOWN = NKF::UNKNOWN

  #
  # Public Methods
  #

  # call-seq:
  #    Kconv.kconv(str, to_enc, from_enc=nil)
  #
  # Convert <code>str</code> to <code>to_enc</code>.
  # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
  def kconv(str, to_enc, from_enc=nil)
    opt = ''
    opt += ' --ic=' + from_enc.to_s if from_enc
    opt += ' --oc=' + to_enc.to_s if to_enc

    ::NKF::nkf(opt, str)
  end
  module_function :kconv

  #
  # Encode to
  #

  # call-seq:
  #    Kconv.tojis(str)   => string
  #
  # Convert <code>str</code> to ISO-2022-JP
  def tojis(str)
    kconv(str, JIS)
  end
  module_function :tojis

  # call-seq:
  #    Kconv.toeuc(str)   => string
  #
  # Convert <code>str</code> to EUC-JP
  def toeuc(str)
    kconv(str, EUC)
  end
  module_function :toeuc

  # call-seq:
  #    Kconv.tosjis(str)   => string
  #
  # Convert <code>str</code> to Shift_JIS
  def tosjis(str)
    kconv(str, SJIS)
  end
  module_function :tosjis

  # call-seq:
  #    Kconv.toutf8(str)   => string
  #
  # Convert <code>str</code> to UTF-8
  def toutf8(str)
    kconv(str, UTF8)
  end
  module_function :toutf8

  # call-seq:
  #    Kconv.toutf16(str)   => string
  #
  # Convert <code>str</code> to UTF-16
  def toutf16(str)
    kconv(str, UTF16)
  end
  module_function :toutf16

  # call-seq:
  #    Kconv.toutf32(str)   => string
  #
  # Convert <code>str</code> to UTF-32
  def toutf32(str)
    kconv(str, UTF32)
  end
  module_function :toutf32

  # call-seq:
  #    Kconv.tolocale   => string
  #
  # Convert <code>self</code> to locale encoding
  def tolocale(str)
    kconv(str, Encoding.locale_charmap)
  end
  module_function :tolocale

  #
  # guess
  #

  # call-seq:
  #    Kconv.guess(str)   => encoding
  #
  # Guess input encoding by NKF.guess
  def guess(str)
    ::NKF::guess(str)
  end
  module_function :guess

  #
  # isEncoding
  #

  # call-seq:
  #    Kconv.iseuc(str)   => true or false
  #
  # Returns whether input encoding is EUC-JP or not.
  #
  # *Note* don't expect this return value is MatchData.
  def iseuc(str)
    str.dup.force_encoding(EUC).valid_encoding?
  end
  module_function :iseuc

  # call-seq:
  #    Kconv.issjis(str)   => true or false
  #
  # Returns whether input encoding is Shift_JIS or not.
  def issjis(str)
    str.dup.force_encoding(SJIS).valid_encoding?
  end
  module_function :issjis

  # call-seq:
  #    Kconv.isjis(str)   => true or false
  #
  # Returns whether input encoding is ISO-2022-JP or not.
  def isjis(str)
    /\A [\t\n\r\x20-\x7E]*
      (?:
        (?:\x1b \x28 I      [\x21-\x7E]*
          |\x1b \x28 J      [\x21-\x7E]*
          |\x1b \x24 @      (?:[\x21-\x7E]{2})*
          |\x1b \x24 B      (?:[\x21-\x7E]{2})*
          |\x1b \x24 \x28 D (?:[\x21-\x7E]{2})*
        )*
        \x1b \x28 B [\t\n\r\x20-\x7E]*
      )*
     \z/nox =~ str.dup.force_encoding('BINARY') ? true : false
  end
  module_function :isjis

  # call-seq:
  #    Kconv.isutf8(str)   => true or false
  #
  # Returns whether input encoding is UTF-8 or not.
  def isutf8(str)
    str.dup.force_encoding(UTF8).valid_encoding?
  end
  module_function :isutf8
end

class String
  # call-seq:
  #    String#kconv(to_enc, from_enc)
  #
  # Convert <code>self</code> to <code>to_enc</code>.
  # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
  def kconv(to_enc, from_enc=nil)
    from_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0]
    Kconv::kconv(self, to_enc, from_enc)
  end

  #
  # to Encoding
  #

  # call-seq:
  #    String#tojis   => string
  #
  # Convert <code>self</code> to ISO-2022-JP
  def tojis; Kconv.tojis(self) end

  # call-seq:
  #    String#toeuc   => string
  #
  # Convert <code>self</code> to EUC-JP
  def toeuc; Kconv.toeuc(self) end

  # call-seq:
  #    String#tosjis   => string
  #
  # Convert <code>self</code> to Shift_JIS
  def tosjis; Kconv.tosjis(self) end

  # call-seq:
  #    String#toutf8   => string
  #
  # Convert <code>self</code> to UTF-8
  def toutf8; Kconv.toutf8(self) end

  # call-seq:
  #    String#toutf16   => string
  #
  # Convert <code>self</code> to UTF-16
  def toutf16; Kconv.toutf16(self) end

  # call-seq:
  #    String#toutf32   => string
  #
  # Convert <code>self</code> to UTF-32
  def toutf32; Kconv.toutf32(self) end

  # call-seq:
  #    String#tolocale   => string
  #
  # Convert <code>self</code> to locale encoding
  def tolocale; Kconv.tolocale(self) end

  #
  # is Encoding
  #

  # call-seq:
  #    String#iseuc   => true or false
  #
  # Returns whether <code>self</code>'s encoding is EUC-JP or not.
  def iseuc;	Kconv.iseuc(self) end

  # call-seq:
  #    String#issjis   => true or false
  #
  # Returns whether <code>self</code>'s encoding is Shift_JIS or not.
  def issjis;	Kconv.issjis(self) end

  # call-seq:
  #    String#isjis   => true or false
  #
  # Returns whether <code>self</code>'s encoding is ISO-2022-JP or not.
  def isjis;	Kconv.isjis(self) end

  # call-seq:
  #    String#isutf8   => true or false
  #
  # Returns whether <code>self</code>'s encoding is UTF-8 or not.
  def isutf8;	Kconv.isutf8(self) end
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
3 Mar 2024 10.43 PM
root / root
0755
cgi
--
3 Mar 2024 10.43 PM
root / linksafe
0755
date
--
3 Mar 2024 10.43 PM
root / linksafe
0755
digest
--
3 Mar 2024 10.43 PM
root / linksafe
0755
dl
--
3 Mar 2024 10.43 PM
root / linksafe
0755
drb
--
3 Mar 2024 10.43 PM
root / linksafe
0755
fiddle
--
3 Mar 2024 10.43 PM
root / linksafe
0755
io
--
3 Mar 2024 10.43 PM
root / linksafe
0755
irb
--
3 Mar 2024 10.43 PM
root / linksafe
0755
json
--
3 Mar 2024 10.43 PM
root / linksafe
0755
matrix
--
3 Mar 2024 10.43 PM
root / linksafe
0755
net
--
3 Mar 2024 10.43 PM
root / linksafe
0755
openssl
--
3 Mar 2024 10.43 PM
root / linksafe
0755
optparse
--
3 Mar 2024 10.43 PM
root / linksafe
0755
psych
--
3 Mar 2024 10.43 PM
root / linksafe
0755
racc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rake
--
3 Mar 2024 10.53 PM
root / linksafe
0755
rbconfig
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rdoc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rexml
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rinda
--
3 Mar 2024 10.43 PM
root / linksafe
0755
ripper
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rss
--
3 Mar 2024 10.43 PM
root / linksafe
0755
rubygems
--
3 Mar 2024 10.43 PM
root / linksafe
0755
shell
--
3 Mar 2024 10.43 PM
root / linksafe
0755
syslog
--
3 Mar 2024 10.43 PM
root / root
0755
test
--
3 Mar 2024 10.43 PM
root / linksafe
0755
uri
--
3 Mar 2024 10.43 PM
root / linksafe
0755
webrick
--
3 Mar 2024 10.43 PM
root / linksafe
0755
x86_64-linux
--
3 Mar 2024 10.43 PM
root / root
0755
xmlrpc
--
3 Mar 2024 10.43 PM
root / linksafe
0755
yaml
--
3 Mar 2024 10.43 PM
root / linksafe
0755
English.rb
6.443 KB
4 Feb 2013 2.50 AM
root / linksafe
0644
abbrev.rb
3.313 KB
21 Feb 2013 5.35 PM
root / linksafe
0644
base64.rb
2.631 KB
19 May 2013 3.10 AM
root / linksafe
0644
benchmark.rb
17.952 KB
20 Sep 2013 4.05 PM
root / linksafe
0644
cgi.rb
9.841 KB
18 Jul 2013 1.50 PM
root / linksafe
0644
cmath.rb
8.927 KB
3 Jul 2015 9.12 AM
root / linksafe
0644
complex.rb
0.371 KB
16 Aug 2009 3.34 PM
root / linksafe
0644
csv.rb
81.682 KB
14 Sep 2014 3.25 PM
root / linksafe
0644
date.rb
0.924 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
debug.rb
29.077 KB
14 Dec 2013 2.48 PM
root / linksafe
0644
delegate.rb
11.125 KB
2 Feb 2014 1.46 PM
root / linksafe
0644
digest.rb
2.338 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
dl.rb
0.273 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
drb.rb
0.019 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
e2mmap.rb
3.891 KB
17 Dec 2013 11.20 AM
root / linksafe
0644
erb.rb
26.073 KB
11 Aug 2014 2.55 PM
root / linksafe
0644
expect.rb
2.144 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
fiddle.rb
1.652 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
fileutils.rb
47.171 KB
28 Apr 2015 5.16 AM
root / linksafe
0644
find.rb
2.359 KB
15 Oct 2014 3.31 PM
root / linksafe
0644
forwardable.rb
7.863 KB
23 May 2013 9.46 PM
root / linksafe
0644
getoptlong.rb
15.381 KB
19 May 2013 2.50 PM
root / linksafe
0644
gserver.rb
8.856 KB
6 Jul 2014 1.57 PM
root / linksafe
0644
ipaddr.rb
17.051 KB
29 Oct 2015 2.36 PM
root / linksafe
0644
irb.rb
20.034 KB
25 Mar 2016 8.22 AM
root / linksafe
0644
json.rb
1.737 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
kconv.rb
5.737 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
logger.rb
22.371 KB
25 Feb 2016 11.04 AM
root / linksafe
0644
mathn.rb
6.524 KB
26 Aug 2011 10.22 PM
root / linksafe
0644
matrix.rb
45.432 KB
11 Jul 2014 2.08 PM
root / linksafe
0644
mkmf.rb
80.503 KB
26 Jul 2023 2.19 PM
root / linksafe
0644
monitor.rb
6.935 KB
16 Nov 2012 4.55 PM
root / linksafe
0644
mutex_m.rb
2.002 KB
20 Feb 2013 2.51 AM
root / linksafe
0644
observer.rb
5.807 KB
21 Nov 2013 4.44 AM
root / linksafe
0644
open-uri.rb
24.268 KB
22 Feb 2014 8.54 AM
root / linksafe
0644
open3.rb
20.366 KB
1 Dec 2013 3.13 AM
root / linksafe
0644
openssl.rb
0.516 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
optparse.rb
50.796 KB
28 Nov 2013 7.34 AM
root / linksafe
0644
ostruct.rb
7.702 KB
23 Oct 2013 3.14 PM
root / linksafe
0644
pathname.rb
15.297 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
pp.rb
14.097 KB
22 Oct 2013 9.29 AM
root / linksafe
0644
prettyprint.rb
16.331 KB
19 May 2013 3.10 AM
root / linksafe
0644
prime.rb
13.203 KB
15 Jul 2013 4.21 AM
root / linksafe
0644
profile.rb
0.2 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
profiler.rb
4.509 KB
19 May 2013 11.04 PM
root / linksafe
0644
pstore.rb
14.849 KB
11 Nov 2012 4.23 AM
root / linksafe
0644
psych.rb
14.878 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
rake.rb
2.116 KB
11 Oct 2013 9.35 PM
root / linksafe
0644
rational.rb
0.301 KB
24 Sep 2009 12.42 AM
root / linksafe
0644
rdoc.rb
4.921 KB
22 Dec 2013 10.25 AM
root / linksafe
0644
resolv-replace.rb
1.732 KB
11 Mar 2013 1.47 PM
root / linksafe
0644
resolv.rb
72.308 KB
13 May 2015 5.33 AM
root / linksafe
0644
ripper.rb
2.525 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
rss.rb
2.841 KB
11 May 2011 10.22 AM
root / linksafe
0644
rubygems.rb
30.974 KB
26 Jul 2023 2.19 PM
root / linksafe
0644
scanf.rb
23.542 KB
14 Dec 2013 2.55 AM
root / linksafe
0644
securerandom.rb
8.49 KB
7 Nov 2013 6.04 PM
root / linksafe
0644
set.rb
18.704 KB
22 Nov 2013 11.50 PM
root / linksafe
0644
shell.rb
10.299 KB
19 May 2013 3.10 AM
root / linksafe
0644
shellwords.rb
5.941 KB
14 Dec 2013 6.26 PM
root / linksafe
0644
singleton.rb
4.018 KB
18 May 2011 2.09 PM
root / linksafe
0644
socket.rb
25.596 KB
26 Jul 2023 2.22 PM
root / linksafe
0644
sync.rb
7.255 KB
19 May 2013 3.10 AM
root / linksafe
0644
tempfile.rb
11.398 KB
21 Nov 2013 9.28 AM
root / linksafe
0644
thwait.rb
3.377 KB
7 Nov 2013 5.02 PM
root / linksafe
0644
time.rb
21.316 KB
17 Aug 2015 7.41 AM
root / linksafe
0644
timeout.rb
3.697 KB
17 Aug 2015 7.55 AM
root / linksafe
0644
tmpdir.rb
4.149 KB
19 May 2013 3.10 AM
root / linksafe
0644
tracer.rb
6.402 KB
18 Jul 2013 1.50 PM
root / linksafe
0644
tsort.rb
14.145 KB
17 Oct 2013 3.59 PM
root / linksafe
0644
ubygems.rb
0.262 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
un.rb
8.873 KB
5 Jul 2013 1.43 PM
root / linksafe
0644
uri.rb
3.07 KB
13 May 2011 8.03 PM
root / linksafe
0644
weakref.rb
3.229 KB
9 Nov 2013 10.42 PM
root / linksafe
0644
webrick.rb
6.689 KB
5 Oct 2013 11.39 PM
root / linksafe
0644
xmlrpc.rb
8.488 KB
12 Dec 2013 3.09 AM
root / linksafe
0644
yaml.rb
2.313 KB
12 Aug 2013 3.49 AM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF