/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
// Assume the utf8 string is in legal form and has been
default:
length = 1;
break;
case 0x8: case 0x9: case 0xA: case 0xB: case 0xF:
/* Shouldn't happen. */
break;
case 0xC: case 0xD:
/* 110xxxxx 10xxxxxx */
length = 2;
break;
}
break;
case 0xE:
/* 1110xxxx 10xxxxxx 10xxxxxx */
length = 3;
}
}
break;
} /* end of switch */
if (length <= 0) {
}
// The assert is correct but the .class file is wrong
// assert(UNICODE::utf8_size(result) == length, "checking reverse computation");
}
/* See if it's legal supplementary character:
11101101 1010xxxx 10xxxxxx 11101101 1011xxxx 10xxxxxx */
if (is_supplementary_character(ptr)) {
return (char *)(ptr + 6);
}
return next_ch;
}
// Count bytes of the form 10xxxxxx and deduct this count
// from the total byte count. The utf8 string must be in
// legal form which has been verified in the format checker.
for (int i = 0; i < len; i++) {
--num_chars;
}
}
return num_chars;
}
// Count bytes of the utf8 string except those in form
// 10xxxxxx which only appear in multibyte characters.
// The utf8 string must be in legal form and has been
// verified in the format checker.
int num_chars = 0;
for (const char* p = str; *p; p++) {
if (((*p) & 0xC0) != 0x80) {
num_chars++;
}
}
return num_chars;
}
// Writes a jchar a utf8 and returns the end
return base + 1;
}
if (ch <= 0x7FF) {
/* 11 bits or less. */
return base + 2;
}
/* possibly full 16 bits. */
return base + 3;
}
unsigned char ch;
int index = 0;
/* ASCII case loop optimization */
}
}
}
// Returns NULL if 'c' it not found. This only works as long
// as 'c' is an ASCII character
assert(c >= 0, "does not work for non-ASCII characters");
// Skip backwards in string until 'c' is found or end is reached
}
// Length must be the same
for (int i = 0; i < length1; i++) {
}
return true;
}
}
}
//-------------------------------------------------------------------------------------
if ((0x0001 <= c) && (c <= 0x007F)) return 1;
if (c <= 0x07FF) return 2;
return 3;
}
int result = 0;
else result += 3;
}
return result;
}
}
*p = '\0';
return (char*) result;
}
}
*p = '\0';
return buf;
}
}
*utf8_buffer = '\0';
}