class WirisPlugin::UrlUtils

Public Class Methods

charCode0() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 38
def self.charCode0
    @@charCode0
end
charCode0=(charCode0) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 41
def self.charCode0=(charCode0)
    @@charCode0 = charCode0
end
charCode9() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 45
def self.charCode9
    @@charCode9
end
charCode9=(charCode9) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 48
def self.charCode9=(charCode9)
    @@charCode9 = charCode9
end
charCodeA() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 10
def self.charCodeA
    @@charCodeA
end
charCodeA=(charCodeA) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 13
def self.charCodeA=(charCodeA)
    @@charCodeA = charCodeA
end
charCodeZ() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 17
def self.charCodeZ
    @@charCodeZ
end
charCodeZ=(charCodeZ) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 20
def self.charCodeZ=(charCodeZ)
    @@charCodeZ = charCodeZ
end
charCodea() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 24
def self.charCodea
    @@charCodea
end
charCodea=(charCodea) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 27
def self.charCodea=(charCodea)
    @@charCodea = charCodea
end
charCodez() click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 31
def self.charCodez
    @@charCodez
end
charCodez=(charCodez) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 34
def self.charCodez=(charCodez)
    @@charCodez = charCodez
end
isAllowed(c) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 51
def self.isAllowed(c)
    allowedChars = "-_.!~*\'()"::indexOf(Std::fromCharCode(c)) != -1
    return ((((c >= @@charCodeA) && (c <= @@charCodeZ)) || ((c >= @@charCodea) && (c <= @@charCodez))) || ((c >= @@charCode0) && (c <= @@charCode9))) || allowedChars
end
new() click to toggle source
Calls superclass method
# File lib/com/wiris/util/type/UrlUtils.rb, line 6
def initialize()
    super()
end
urlComponentEncode(uriComponent) click to toggle source
# File lib/com/wiris/util/type/UrlUtils.rb, line 55
def self.urlComponentEncode(uriComponent)
    sb = StringBuf.new()
    buf = Bytes::ofData(Utf8::toBytes(uriComponent))
    for i in 0..buf::length() - 1
        b = buf::get(i)&255
        if UrlUtils.isAllowed(b)
            sb::add(Std::fromCharCode(b))
        else 
            sb::add("%")
            sb::add(StringTools::hex(b,2))
        end
        i+=1
    end
    return sb::toString()
end