length

wkov/colony/length

No description
length
@/length
STRstring
String value.
length
LEN
STR
LENnumber
String length.
To use the node in your project you should have the wkov/colony library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

node {

    void evaluate(Context ctx) {
        auto str = getValue<input_STR>(ctx);

        unsigned char hex;
        uint8_t result = 0;

        for (auto it = str.iterate(); it; ++it) {
            hex = *it;
            if (hex != 0xd0 && hex != 0xd1) {
                result++;
            }
        }

        emitValue<output_LEN>(ctx, result);
    }
}

Tabular tests

STRLEN
""0
"Hello World!"12
"Привет World!"13
"Hello Мир!"10
"Привет Мир!"11