Author: wyoung
Date: Thu Mar 29 20:02:50 2007
New Revision: 1484
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1484&view=rev
Log:
Removed utf8trans() routine from examples/util module, now that we have
GUI Windows examples, which showcase Unicode translation much more
realistically.
Modified:
trunk/examples/simple1.cpp
trunk/examples/simple2.cpp
trunk/examples/util.cpp
trunk/examples/util.h
Modified: trunk/examples/simple1.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/simple1.cpp?rev=1484&r1=1483&r2=1484&view=diff
==============================================================================
--- trunk/examples/simple1.cpp (original)
+++ trunk/examples/simple1.cpp Thu Mar 29 20:02:50 2007
@@ -3,7 +3,7 @@
table with MySQL++.
Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
- MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
+ MySQL AB, and (c) 2004-2007 by Educational Technology Resources, Inc.
Others may also hold copyrights on code in this file. See the CREDITS
file in the top directory of the distribution for details.
@@ -51,11 +51,10 @@
// Display the result set
cout << "We have:" << endl;
if (res) {
- char buf[100];
mysqlpp::Row row;
mysqlpp::Row::size_type i;
for (i = 0; row = res.at(i); ++i) {
- cout << '\t' << utf8trans(row.at(0), buf, sizeof(buf))
<< endl;
+ cout << '\t' << row.at(0) << endl;
}
}
else {
Modified: trunk/examples/simple2.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/simple2.cpp?rev=1484&r1=1483&r2=1484&view=diff
==============================================================================
--- trunk/examples/simple2.cpp (original)
+++ trunk/examples/simple2.cpp Thu Mar 29 20:02:50 2007
@@ -3,7 +3,7 @@
using a "store" query, and prints it out.
Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
- MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
+ MySQL AB, and (c) 2004-2007 by Educational Technology Resources, Inc.
Others may also hold copyrights on code in this file. See the CREDITS
file in the top directory of the distribution for details.
@@ -59,12 +59,10 @@
"Date" << endl << endl;
// Get each row in result set, and print its contents
- char buf[100];
mysqlpp::Row row;
mysqlpp::Row::size_type i;
for (i = 0; row = res.at(i); ++i) {
- cout << setw(20) <<
- utf8trans(row["item"], buf,
sizeof(buf)) << ' ' <<
+ cout << setw(20) << row["item"] << ' ' <<
setw(9) << row["num"] << ' ' <<
setw(9) << row["weight"] << ' ' <<
setw(9) << row["price"] << ' ' <<
Modified: trunk/examples/util.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/util.cpp?rev=1484&r1=1483&r2=1484&view=diff
==============================================================================
--- trunk/examples/util.cpp (original)
+++ trunk/examples/util.cpp Thu Mar 29 20:02:50 2007
@@ -29,7 +29,7 @@
#include <iostream>
#include <iomanip>
-#include <stdlib.h>
+//#include <stdlib.h>
// This include isn't needed by util module. It's just a test of the
// new SSQLS feature allowing the structure to be defined in many
@@ -46,51 +46,6 @@
const char* kpcSampleDatabase = "mysql_cpp_data";
-//// utf8trans /////////////////////////////////////////////////////////
-// Converts a Unicode string encoded in UTF-8 form (which the MySQL
-// database uses) to a form suitable for outputting to the standard C++
-// cout stream. Functionality is platform-specific.
-
-char*
-utf8trans(const char* utf8_str, char* out_buf, int buf_len)
-{
-#ifdef MYSQLPP_PLATFORM_WINDOWS
- // It's Win32, so assume console output, where output needs to be in
- // local ANSI code page by default.
- wchar_t ucs2_buf[100];
- static const int ub_chars = sizeof(ucs2_buf) / sizeof(ucs2_buf[0]);
-
- // First, convert UTF-8 string to UCS-2
- if (MultiByteToWideChar(CP_UTF8, 0, utf8_str, -1,
- ucs2_buf, ub_chars) > 0) {
- // Next, convert UCS-2 to local code page.
- CPINFOEX cpi;
- GetCPInfoEx(CP_OEMCP, 0, &cpi);
- WideCharToMultiByte(cpi.CodePage, 0, ucs2_buf, -1,
- out_buf, buf_len, 0, 0);
- return out_buf;
- }
- else {
- int err = GetLastError();
- if (err == ERROR_NO_UNICODE_TRANSLATION) {
- cerr << "Bad data in UTF-8 string" << endl;
- }
- else {
- cerr << "Unknown error in Unicode translation: " <<
- GetLastError() << endl;
- }
- return 0;
- }
-#else
- // Assume a modern Unixy platform, where the system's terminal I/O
- // code handles UTF-8 directly. (e.g. common Linux distributions
- // since 2001 or so, recent versions of Mac OS X, etc.)
- strncpy(out_buf, utf8_str, buf_len);
- return out_buf;
-#endif
-}
-
-
//// print_stock_header ////////////////////////////////////////////////
// Display a header suitable for use with print_stock_rows().
@@ -116,11 +71,8 @@
mysqlpp::sql_double weight, mysqlpp::sql_double price,
const mysqlpp::sql_date& date)
{
- // We do UTF-8 translation on item field because there is Unicode
- // data in this field in the sample database, and some systems
- // cannot handle UTF-8 sent directly to cout.
char buf[100];
- cout << setw(20) << utf8trans(item.c_str(), buf, sizeof(buf)) << ' ' <<
+ cout << setw(20) << item << ' ' <<
setw(9) << num << ' ' <<
setw(9) << weight << ' ' <<
setw(9) << price << ' ' <<
Modified: trunk/examples/util.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/util.h?rev=1484&r1=1483&r2=1484&view=diff
==============================================================================
--- trunk/examples/util.h (original)
+++ trunk/examples/util.h Thu Mar 29 20:02:50 2007
@@ -44,7 +44,6 @@
const char* extra_parms = "");
bool connect_to_db(int argc, char *argv[], mysqlpp::Connection& con,
const char* kdb = 0);
-char* utf8trans(const char* utf8_str, char* ansi_str, int ansi_len);
#endif // !defined(MYSQLPP_UTIL_H)
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits