String library.

Dependents:   CheckSum RN41 RealTimeClock TVZ_MU_Seminar ... more

Revision:
1:7c89cd414311
Parent:
0:058192932ad2
Child:
2:14f3ff21096e
--- a/StrLib.cpp	Thu Jun 11 01:50:08 2015 +0000
+++ b/StrLib.cpp	Mon Jun 29 01:51:12 2015 +0000
@@ -56,4 +56,26 @@
     if(id == string::npos)
         return false;
     return id == idx;
+}
+
+string toAlpanumeric(string str, bool toLarge)
+{
+    string ans= "";
+    bool num, small, large;
+    for (int i= 0; i < str.size(); i++) {
+        num= small= large= false;
+        if('0' <= str[i] && str[i] <= '9')
+            num= true;
+        else if('A' <= str[i] && str[i] <= 'Z')
+            large= true;
+        else if('a' <= str[i] && str[i] <= 'z')
+            small= true;
+        
+        if(toLarge && small)
+            str[i] -= 0x20;  // small -> large
+        if(num || large || small)
+            ans += str[i];
+    }
+    
+    return ans;
 }
\ No newline at end of file