diff --git a/api/String.cpp b/api/String.cpp index 4f176374..2423584c 100644 --- a/api/String.cpp +++ b/api/String.cpp @@ -747,4 +747,38 @@ double String::toDouble(void) const return 0; } +String String::fromUtf8ToEAscii(void) const +{ + /* + * references : + * https://www.ime.usp.br/~pf/algoritmos/apend/unicode.html + * https://www.utf8-chartable.de/unicode-utf8-table.pl + * https://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + */ + String eAsciiString; + for (uint8_t i=0; i< length(); i++) + { + uint8_t byteScope = (uint8_t)buffer[i]; + if (byteScope < 0x7F) + { + eAsciiString += buffer[i]; + } + else if (byteScope == 0xC3) + { + i++; + byteScope = (uint8_t)buffer[i]; + if (byteScope > 0x7F) + eAsciiString += (char)(byteScope+0x40); + } + else if (byteScope == 0xC2) + { + i++; + byteScope = (uint8_t)buffer[i]; + if (byteScope > 0x7F) + eAsciiString += (char)(byteScope); + } + } + return eAsciiString; +} + } // namespace arduino diff --git a/api/String.h b/api/String.h index 0bafd35a..11a83b4a 100644 --- a/api/String.h +++ b/api/String.h @@ -215,6 +215,7 @@ class String long toInt(void) const; float toFloat(void) const; double toDouble(void) const; + String fromUtf8ToEAscii(void) const; protected: char *buffer; // the actual char array pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy