|
@@ -0,0 +1,50 @@
|
|
1
|
+//
|
|
2
|
+// Created by robin on 1/8/16.
|
|
3
|
+//
|
|
4
|
+
|
|
5
|
+#ifdef ARD_UTILS_DELAYMS
|
|
6
|
+void ArdUtils::delayMs(unsigned ms)
|
|
7
|
+{
|
|
8
|
+ for (unsigned i = 0; i < ms; i++) {
|
|
9
|
+ delayMicroseconds(1000);
|
|
10
|
+ }
|
|
11
|
+}
|
|
12
|
+#endif
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+#ifdef ARD_UTILS_UTF8
|
|
16
|
+byte ArdUtils::_utf8ToAscii(byte ascii, byte& c1)
|
|
17
|
+{
|
|
18
|
+ if ( ascii<128 ) // Standard ASCII-set 0..0x7F handling
|
|
19
|
+ { c1=0;
|
|
20
|
+ return( ascii );
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ // get previous input
|
|
24
|
+ byte last = c1; // get last char
|
|
25
|
+ c1=ascii; // remember actual character
|
|
26
|
+
|
|
27
|
+ switch (last) // conversion depnding on first UTF8-character
|
|
28
|
+ { case 0xC2: return (ascii); break;
|
|
29
|
+ case 0xC3: return (ascii | 0xC0); break;
|
|
30
|
+ case 0x82: if(ascii==0xAC) return(0x80); // special case Euro-symbol
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ return (0); // otherwise: return zero, if character has to be ignored
|
|
34
|
+}
|
|
35
|
+
|
|
36
|
+void ArdUtils::utf8ToAscii(char* s)
|
|
37
|
+{
|
|
38
|
+ byte c1 = 0;
|
|
39
|
+ int k=0;
|
|
40
|
+ byte c;
|
|
41
|
+ unsigned len = strlen(s);
|
|
42
|
+ for (unsigned i=0; i<len; i++)
|
|
43
|
+ {
|
|
44
|
+ c = ArdUtils::_utf8ToAscii(s[i], c1);
|
|
45
|
+ if (c!=0)
|
|
46
|
+ s[k++]=c;
|
|
47
|
+ }
|
|
48
|
+ s[k]=0;
|
|
49
|
+}
|
|
50
|
+#endif
|