module Myhtml::Utils::DetectEncoding

Defined in:

myhtml/utils/detect_encoding.cr

Class Method Summary

Class Method Detail

def self.detect(pointer, bytesize) #

[View source]
def self.detect(content : String) #

Detects encoding by trigrams slow and not 100% correct


[View source]
def self.detect?(pointer, bytesize) #

[View source]
def self.detect?(content : String) #

[View source]
def self.from_header(header : String) : Lib::MyEncodingList | EncodingNotFound #

Detect encoding from header example: Myhtml::Utils::DetectEncoding.from_header(headers["Content-Type"]) # => MyHTML_ENCODING_WINDOWS_1251 Myhtml::Utils::DetectEncoding.from_header("text/html; charset=Windows-1251") # => MyHTML_ENCODING_WINDOWS_1251


[View source]
def self.from_header?(header) : Lib::MyEncodingList | Nil #

[View source]
def self.from_meta(pointer, bytesize) #

[View source]
def self.from_meta(content : String) #

Detect encoding from meta tag in content example: Myhtml::Utils::DetectEncoding.from_meta(content) # => MyHTML_ENCODING_WINDOWS_1251 Myhtml::Utils::DetectEncoding.from_meta(%Q{ }) # => MyHTML_ENCODING_WINDOWS_1251


[View source]
def self.from_meta?(pointer, bytesize) #

[View source]
def self.from_meta?(content : String) #

[View source]