guess2(p1)
public
Returns guessed encoding of str as integer by nkf routine.
case NKF.guess(input)
when NKF::ASCII
"ASCII"
when NKF::JIS
"ISO-2022-JP"
when NKF::SJIS
"Shift_JIS"
when NKF::EUC
"EUC-JP"
when NKF::UTF8
"UTF-8"
when NKF::UTF16
"UTF-16"
when NKF::UNKNOWN
"UNKNOWN"
when NKF::BINARY
"BINARY"
end
Show source
/*
* call-seq:
* NKF.guess2(str) -> integer
*
* Returns guessed encoding of _str_ as integer by nkf routine.
*
* case NKF.guess(input)
* when NKF::ASCII
* "ASCII"
* when NKF::JIS
* "ISO-2022-JP"
* when NKF::SJIS
* "Shift_JIS"
* when NKF::EUC
* "EUC-JP"
* when NKF::UTF8
* "UTF-8"
* when NKF::UTF16
* "UTF-16"
* when NKF::UNKNOWN
* "UNKNOWN"
* when NKF::BINARY
* "BINARY"
* end
*/
static VALUE
rb_nkf_guess2(obj, src)
VALUE obj, src;
{
int code = _BINARY;
reinit();
input_ctr = 0;
StringValue(src);
input = (unsigned char *)RSTRING(src)->ptr;
i_len = RSTRING(src)->len;
if(x0201_f == WISH_TRUE)
x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
guess_f = TRUE;
kanji_convert( NULL );
guess_f = FALSE;
if (!is_inputcode_mixed) {
if (strcmp(input_codename, "") == 0) {
code = _ASCII;
} else if (strcmp(input_codename, "ISO-2022-JP") == 0) {
code = _JIS;
} else if (strcmp(input_codename, "EUC-JP") == 0) {
code = _EUC;
} else if (strcmp(input_codename, "Shift_JIS") == 0) {
code = _SJIS;
} else if (strcmp(input_codename, "UTF-8") == 0) {
code = _UTF8;
} else if (strcmp(input_codename, "UTF-16") == 0) {
code = _UTF16;
} else if (strlen(input_codename) > 0) {
code = _UNKNOWN;
}
}
return INT2FIX( code );
}