[gnote] Make sharp::string_to_lowercase, sharp::string_substring Unicode aware



commit 66f767499be801f5bb7389b50c1f0da22b2b6ce7
Author: Debarshi Ray <debarshir src gnome org>
Date:   Mon Mar 15 03:13:30 2010 +0200

    Make sharp::string_to_lowercase, sharp::string_substring Unicode aware
    
    Fixes: https://bugzilla.gnome.org/610406

 src/sharp/string.cpp |   12 ++++++------
 src/sharp/string.hpp |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/sharp/string.cpp b/src/sharp/string.cpp
index 0066667..92244d9 100644
--- a/src/sharp/string.cpp
+++ b/src/sharp/string.cpp
@@ -76,18 +76,18 @@ namespace sharp {
     boost::split(split, source, boost::is_any_of(delimiters));
   }
 
-  std::string string_substring(const std::string & source, int start)
+  Glib::ustring string_substring(const Glib::ustring & source, int start)
   {
     DBG_ASSERT(start >= 0, "start can't be negative");
     if(source.size() <= (unsigned int)start) {
       return "";
     }
-    return std::string(source.begin() + start, source.end());
+    return Glib::ustring(source, start, std::string::npos);
   }
 
-  std::string string_substring(const std::string & source, int start, int len)
+  Glib::ustring string_substring(const Glib::ustring & source, int start, int len)
   {
-    return std::string(source.begin() + start, source.begin() + start + len);
+    return Glib::ustring(source, start, len);
   }
 
   std::string string_trim(const std::string & source)
@@ -155,9 +155,9 @@ namespace sharp {
   }
 
 
-  std::string string_to_lower(const std::string & source)
+  Glib::ustring string_to_lower(const Glib::ustring & source)
   {
-    return boost::to_lower_copy(source);
+    return source.lowercase();
   }
 
 }
diff --git a/src/sharp/string.hpp b/src/sharp/string.hpp
index 4ef6f22..628eaab 100644
--- a/src/sharp/string.hpp
+++ b/src/sharp/string.hpp
@@ -58,9 +58,9 @@ namespace sharp {
                     const char * delimiters);
 
   /** copy the substring for %source, starting at %start until the end */
-  std::string string_substring(const std::string & source, int start);
+  Glib::ustring string_substring(const Glib::ustring & source, int start);
   /** copy the substring for %source, starting at %start and running for %len */
-  std::string string_substring(const std::string & source, int start, int len);
+  Glib::ustring string_substring(const Glib::ustring & source, int start, int len);
 
   std::string string_trim(const std::string & source);
   std::string string_trim(const std::string & source, const char * set_of_char);
@@ -70,7 +70,7 @@ namespace sharp {
   int string_index_of(const std::string & source, const std::string & with, int);
   int string_last_index_of(const std::string & source, const std::string & with);
 
-  std::string string_to_lower(const std::string & source);
+  Glib::ustring string_to_lower(const Glib::ustring & source);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]