< prev index next >
src/hotspot/share/utilities/utf8.cpp
Print this page
@@ -399,11 +399,11 @@
bool UNICODE::is_latin1(jchar c) {
return (c <= 0x00FF);
}
-bool UNICODE::is_latin1(jchar* base, int length) {
+bool UNICODE::is_latin1(const jchar* base, int length) {
for (int index = 0; index < length; index++) {
if (base[index] > 0x00FF) {
return false;
}
}
@@ -432,31 +432,31 @@
return 2;
}
}
template<typename T>
-int UNICODE::utf8_length(T* base, int length) {
+int UNICODE::utf8_length(const T* base, int length) {
int result = 0;
for (int index = 0; index < length; index++) {
T c = base[index];
result += utf8_size(c);
}
return result;
}
template<typename T>
-char* UNICODE::as_utf8(T* base, int& length) {
+char* UNICODE::as_utf8(const T* base, int& length) {
int utf8_len = utf8_length(base, length);
u_char* buf = NEW_RESOURCE_ARRAY(u_char, utf8_len + 1);
char* result = as_utf8(base, length, (char*) buf, utf8_len + 1);
assert((int) strlen(result) == utf8_len, "length prediction must be correct");
// Set string length to uft8 length
length = utf8_len;
return (char*) result;
}
-char* UNICODE::as_utf8(jchar* base, int length, char* buf, int buflen) {
+char* UNICODE::as_utf8(const jchar* base, int length, char* buf, int buflen) {
u_char* p = (u_char*)buf;
for (int index = 0; index < length; index++) {
jchar c = base[index];
buflen -= utf8_size(c);
if (buflen <= 0) break; // string is truncated
@@ -464,11 +464,11 @@
}
*p = '\0';
return buf;
}
-char* UNICODE::as_utf8(jbyte* base, int length, char* buf, int buflen) {
+char* UNICODE::as_utf8(const jbyte* base, int length, char* buf, int buflen) {
u_char* p = (u_char*)buf;
u_char* end = (u_char*)buf + buflen;
for (int index = 0; index < length; index++) {
jbyte c = base[index];
int sz = utf8_size(c);
@@ -494,11 +494,11 @@
*utf8_buffer = '\0';
}
// returns the quoted ascii length of a unicode string
template<typename T>
-int UNICODE::quoted_ascii_length(T* base, int length) {
+int UNICODE::quoted_ascii_length(const T* base, int length) {
int result = 0;
for (int i = 0; i < length; i++) {
T c = base[i];
if (c >= 32 && c < 127) {
result++;
@@ -527,13 +527,13 @@
}
*p = '\0';
}
// Explicit instantiation for all supported types.
-template int UNICODE::utf8_length(jbyte* base, int length);
-template int UNICODE::utf8_length(jchar* base, int length);
-template char* UNICODE::as_utf8(jbyte* base, int& length);
-template char* UNICODE::as_utf8(jchar* base, int& length);
-template int UNICODE::quoted_ascii_length<jbyte>(jbyte* base, int length);
-template int UNICODE::quoted_ascii_length<jchar>(jchar* base, int length);
+template int UNICODE::utf8_length(const jbyte* base, int length);
+template int UNICODE::utf8_length(const jchar* base, int length);
+template char* UNICODE::as_utf8(const jbyte* base, int& length);
+template char* UNICODE::as_utf8(const jchar* base, int& length);
+template int UNICODE::quoted_ascii_length<jbyte>(const jbyte* base, int length);
+template int UNICODE::quoted_ascii_length<jchar>(const jchar* base, int length);
template void UNICODE::as_quoted_ascii<jbyte>(const jbyte* base, int length, char* buf, int buflen);
template void UNICODE::as_quoted_ascii<jchar>(const jchar* base, int length, char* buf, int buflen);
< prev index next >