From 4039d395d53af2f4ffb94d3ad189395927c912e8 Mon Sep 17 00:00:00 2001 From: ntrifunovic Date: Fri, 3 Jul 2009 15:28:31 +0000 Subject: [PATCH] Updated the docsample sample git-svn-id: http://svn.code.sf.net/p/utfcpp/code@89 a809a056-fc17-0410-9590-b4f493f8b08e Conflicts: v2_0/samples/docsample.cpp --- samples/docsample.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/samples/docsample.cpp b/samples/docsample.cpp index fc8f6f3..6f8953b 100644 --- a/samples/docsample.cpp +++ b/samples/docsample.cpp @@ -21,20 +21,10 @@ int main(int argc, char** argv) return 0; } - // Read the first line of the file unsigned line_count = 1; string line; - if (!getline(fs8, line)) - return 0; - - // Look for utf-8 byte-order mark at the beginning - if (line.size() > 2) { - if (utf8::is_bom(line.c_str())) - cout << "There is a byte order mark at the beginning of the file\n"; - } - // Play with all the lines in the file - do { + while (getline(fs8, line)) { // check for invalid utf-8 (for a simple yes/no check, there is also utf8::is_valid function) string::iterator end_it = utf8::find_invalid(line.begin(), line.end()); if (end_it != line.end()) { @@ -55,9 +45,8 @@ int main(int argc, char** argv) if (utf8line != string(line.begin(), end_it)) cout << "Error in UTF-16 conversion at line: " << line_count << "\n"; - getline(fs8, line); line_count++; - } while (!fs8.eof()); + } return 0; }