Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

String: Add fromUtf8ToEAscii.#177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
JunioCesarFerreira wants to merge3 commits intoarduino:master
base:master
Choose a base branch
Loading
fromJunioCesarFerreira:feature/fromUtf8ToEAscii-method-in-String
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletionsapi/String.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -747,4 +747,38 @@
return 0;
}

String String::fromUtf8ToEAscii(void) const
{
/*
* references :
* https://www.ime.usp.br/~pf/algoritmos/apend/unicode.html

Check failure on line 754 in api/String.cpp

View workflow job for this annotation

GitHub Actions/ spellcheck

apend ==> append
* 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
1 change: 1 addition & 0 deletionsapi/String.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp