Home | History | Annotate | Download | only in strings
      1 // This file contains string processing functions related to
      2 // uppercase, lowercase, etc.
      3 //
      4 // These functions are for ASCII only. If you need to process UTF8 strings,
      5 // take a look at files in i18n/utf8.
      6 
      7 #ifndef DYNAMIC_DEPTH_INTERNAL_STRINGS_CASE_H_  // NOLINT
      8 #define DYNAMIC_DEPTH_INTERNAL_STRINGS_CASE_H_  // NOLINT
      9 
     10 #include <string>
     11 
     12 #include "base/port.h"
     13 
     14 namespace dynamic_depth {
     15 
     16 // Returns true if the two strings are equal, case-insensitively speaking.
     17 // Uses C/POSIX locale.
     18 inline bool StringCaseEqual(const string& s1, const string& s2) {
     19   return strcasecmp(s1.c_str(), s2.c_str()) == 0;
     20 }
     21 
     22 // ----------------------------------------------------------------------
     23 // LowerString()
     24 // LowerStringToBuf()
     25 //    Convert the characters in "s" to lowercase.
     26 //    Works only with ASCII strings; for UTF8, see ToLower in
     27 //    util/utf8/public/unilib.h
     28 //    Changes contents of "s".  LowerStringToBuf copies at most
     29 //    "n" characters (including the terminating '\0')  from "s"
     30 //    to another buffer.
     31 // ----------------------------------------------------------------------
     32 void LowerString(string* s);
     33 
     34 namespace strings {
     35 inline string ToLower(const string& s) {
     36   string out(s);
     37   LowerString(&out);
     38   return out;
     39 }
     40 
     41 }  // namespace strings
     42 }  // namespace dynamic_depth
     43 
     44 #endif  // DYNAMIC_DEPTH_INTERNAL_STRINGS_CASE_H_  // NOLINT
     45