示例#1
0
Span<const uint8_t> Text::get_text() const
{
    if (!_text_record) {
        return Span<const uint8_t>();
    }

    size_t language_code_size = get_language_code().size();

    return make_const_Span(
               _text_record + header_size + language_code_size,
               _text_record_size - header_size - language_code_size
           );
}
示例#2
0
dhvani_Languages detect_language(unsigned short *word, int size)
{
	unsigned short unicode;
	int i = 0;
	/*check each letters from left to right */
	while (i < size) {
		unicode = word[i];
		if (unicode >= 0x0D00 && unicode <= 0x0D6F) {
			return MALAYALAM;
		}
		if (unicode >= 0x0901 && unicode <= 0x097D) {
			/* Marathi mr_IN shares the code points of devangari with Hindi */
			if (getenv("LANG") != NULL
			    && strcmp(getenv("LANG"), "mr_IN") == 0) {
				return MARATHI;	/*giving priority to LANG environment variable */
			} else {
				return HINDI;
			}

		}
		if (unicode >= 0x0C82 && unicode <= 0x0CEF) {

			return KANNADA;
		}
		if (unicode >= 0x0B01 && unicode <= 0x0B71) {

			return ORIYA;
		}
		if (unicode >= 0x0A81 && unicode <= 0x0AF1) {

			return GUJARATI;
		}
		if (unicode >= 0x0C01 && unicode <= 0x0C6F) {

			return TELUGU;
		}

		if (unicode >= 0x0A01 && unicode <= 0x0A74) {

			return PANJABI;
		}
		if (unicode >= 0x0981 && unicode <= 0x09FA) {

			return BENGALI;
		}
		if (unicode >= 0x0B82 && unicode <= 0x0BFA) {

			return TAMIL;
		}
		if (unicode >= 0x060B && unicode <= 0xFEFC) {

			return PASHTO;
		}

		i++;
	}
	/* Another attempt to see whether the LANG env variable is a supported language */
	if (getenv("LANG") != NULL) {
		return get_language_code(getenv("LANG"));
	} else {
		return -1;	/*sigh... unknown language... */
	}
}