summaryrefslogtreecommitdiff
path: root/utf/unicodetext.cc
diff options
context:
space:
mode:
Diffstat (limited to 'utf/unicodetext.cc')
-rw-r--r--utf/unicodetext.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/utf/unicodetext.cc b/utf/unicodetext.cc
index 175d1f9..55ffedf 100644
--- a/utf/unicodetext.cc
+++ b/utf/unicodetext.cc
@@ -14,9 +14,10 @@
// Author: Jim Meehan
-#include <iostream>
+#include <algorithm>
#include <sstream>
#include <cassert>
+#include <cstdio>
#include "phonenumbers/utf/unicodetext.h"
#include "phonenumbers/utf/stringpiece.h"
@@ -31,8 +32,6 @@ using std::stringstream;
using std::max;
using std::hex;
using std::dec;
-using std::cerr;
-using std::endl;
static int CodepointDistance(const char* start, const char* end) {
int n = 0;
@@ -232,7 +231,7 @@ UnicodeText& UnicodeText::Copy(const UnicodeText& src) {
UnicodeText& UnicodeText::CopyUTF8(const char* buffer, int byte_length) {
repr_.Copy(buffer, byte_length);
if (!UniLib:: IsInterchangeValid(buffer, byte_length)) {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.\n");
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
return *this;
@@ -251,7 +250,7 @@ UnicodeText& UnicodeText::TakeOwnershipOfUTF8(char* buffer,
int byte_capacity) {
repr_.TakeOwnershipOf(buffer, byte_length, byte_capacity);
if (!UniLib:: IsInterchangeValid(buffer, byte_length)) {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.\n");
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
return *this;
@@ -270,7 +269,7 @@ UnicodeText& UnicodeText::PointToUTF8(const char* buffer, int byte_length) {
if (UniLib:: IsInterchangeValid(buffer, byte_length)) {
repr_.PointTo(buffer, byte_length);
} else {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.");
repr_.Copy(buffer, byte_length);
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
@@ -367,12 +366,11 @@ void UnicodeText::push_back(char32 c) {
if (UniLib::IsInterchangeValid(buf, len)) {
repr_.append(buf, len);
} else {
- cerr << "Unicode value 0x" << hex << c
- << " is not valid for interchange" << endl;
+ fprintf(stderr, "Unicode value 0x%x is not valid for interchange\n", c);
repr_.append(" ", 1);
}
} else {
- cerr << "Illegal Unicode value: 0x" << hex << c << endl;
+ fprintf(stderr, "Illegal Unicode value: 0x%x\n", c);
repr_.append(" ", 1);
}
}