- Notifications
You must be signed in to change notification settings - Fork1
The Unicode Ethereum Project is an initiative to provide libraries and contracts for Unicode data, algorithms, and utilities for Ethereum developers.
License
devstein/unicode-eth
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The Unicode Ethereum Project is an initiative to provide libraries and contracts for Unicode data, algorithms, and utilities for Ethereum developers.
Want to support the Unicode Ethereum Project? Donate to theGitcoin Grant!
The Unicode Ethereum Project is under active development and has not been deployed the Ethereum Mainnet. We want to get sufficient feedback from the community before committing the resources required to deployed the Unicode Character Database to Ethereum. Please checkoutcontributing to see how you can make an impact!
| Contract | Rinkeby | Ropsten | Polygon Mumbai | Polygon Mainnet | Ethereum Mainnet |
|---|---|---|---|---|---|
| Unicode | 0xA1263c98FA087dfc400003a1F0F8f154705edC53 | 0xe1a5dc72931a1e9c75bfa50787ab0f8f3d666956 | 0xDdF956e33f238bE394787A4C04EF3038E3307802 | ❌ | ❌ |
| UTF8Encoder | 0x11168016803F91611E4ff5a5cd6Db43D7C772707 | 0x9fB43dc6c94763d7158E68da24BE6537Dfa4258a | 0xbC7b39ed8132064eCC00dfD8E5f07f3DD0b38d2B | ❌ | ❌ |
| UnicodeData | 0x37F0927Db2Bad67E708416F3C2FbaAC42A376741 | ❌ | ❌ | ❌ | ❌ |
Unicode data and algorithms are essential to any major programming language. Solidity, like many lower-level programming languages, represent strings as aUTF-8 encoded bytes and does not natively support character-based operations likelength,charAt, orisLowercase. There are popular third-party libraries for string manipulation, likehttps://github.com/Arachnid/solidity-stringutils, but none that provide information about the underlying Unicode characters. If you are building an application or contract that receives user input as strings, understanding user input is critical for any validation, sanitization, or standardization logic.
Unlike libraries in other programming languages, Solidity contracts arestateful. This allows us to not only build out a Unicode Data API, like in other languages, but also store theUnicode Character Database on Ethereum. With the Unicode Character Database accessible within the Ethereum network, it empowers anyone to build out additional APIs and functionality on top of the Unicode Character Database.
As mentioned before, Unicode data and libraries are essential for any major programming language and the Unicode Ethereum Project could not have been possible with out the rich, open source Unicode ecosystem. A few notable projects that helped in getting the Unicode Ethereum Project off the ground were
- https://icu.unicode.org/
- https://github.com/open-i18n/rust-unic/
- https://docs.python.org/3/library/unicodedata.html
import"https://github.com/devstein/unicode-eth/contracts/Unicode.sol";contractMyContract {using Unicodeforstring;function simpleEmailVerification(stringcalldata_email)externalpurereturns (bool) {// '@' exists and is not the first characteruint atSignIdx= _email.indexOf("@");if (atSignIdx== Unicode.CHAR_NOT_FOUND|| atSignIdx==0)returnfalse;// '.' exists and is after @// NOTE: This is an naive example and would fail on valid email addresses like devin.stein@unicode.orguint periodIdx= _email.indexOf(".");if (periodIdx== Unicode.CHAR_NOT_FOUND|| periodIdx< atSignIdx)returnfalse;returntrue; }}
A library for encoding Unicodeuint32 code points their UTF-8 string representation.
import"https://github.com/devstein/unicode-eth/contracts/UTF8Encoder.sol";contractMyContract {using UTF8Encoderforuint32;function codePointToString(uint32_cp)externalpurereturns (stringmemory){return _cp.UTF8Encode(); }}
An API for the Unicode Character Database
// TODOBuilding a new Unicode library and API is a massive undertaking and cannot be done alone! For the Unicode Ethereum Project to be successful, we will need the help of the Ethereum community. All contributions, small or large, are welcome! If you have an idea for feature, starta discussion or make a pull-request.
About
The Unicode Ethereum Project is an initiative to provide libraries and contracts for Unicode data, algorithms, and utilities for Ethereum developers.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.