Giter Site home page Giter Site logo

stringutils's Introduction

StringUtils

tests

STM32 Utilities and tools for working with Strings.

Features

  • No dynamic memory allocation

Add as CPM project dependency

How to add CPM to the project, check the link

CPMAddPackage(
        NAME StringUtils
        GITHUB_REPOSITORY ximtech/StringUtils
        GIT_TAG origin/main)

target_link_libraries(${PROJECT_NAME} StringUtils)
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
# For Clion STM32 plugin generated Cmake use 
target_link_libraries(${PROJECT_NAME}.elf StringUtils)

Usage

Example of usage:

printf("Is string empty: %s\n", isStringEmpty("") ? "Yes" : "No");  // Yes
printf("Is string not empty: %s\n", isStringNotEmpty(" ") ? "Yes" : "No");  // Yes
printf("Is string empty: %s\n\n", isStringEmpty(NULL) ? "Yes" : "No");  // Yes

printf("Is string blank: %s\n", isStringBlank("   ") ? "Yes" : "No");  // Yes
printf("Is string blank: %s\n", isStringBlank("\t  \r") ? "Yes" : "No");  // Yes
printf("Is string blank: %s\n", isStringBlank(NULL) ? "Yes" : "No");  // Yes
printf("Is string not blank: %s\n\n", isStringNotBlank("   t") ? "Yes" : "No");  // Yes

printf("Have substring: %s\n\n", containsString("Hello world!", "world") ? "Yes" : "No");  // Yes

char buffer[50] = {0};
strcpy(buffer, "HeLlO WoRlD!");
toLowerCaseString(buffer);
printf("To lower case: %s\n", buffer);   // hello world!

toUpperCaseString(buffer);
printf("To upper case: %s\n\n", buffer);   // HELLO WORLD!

memset(buffer, 0, 50);
substringString("Start: ", " :End", "Some string Start: test :End", buffer);
printf("Substring: %s\n", buffer);  // test

memset(buffer, 0, 50);
strcpy(buffer, "Hello world!");
replaceString(buffer, "world", "all");  // Hello all!
printf("Replaced string: %s\n", buffer);

printf("Occurrences of 'ab' in string: %d\n", countStringOccurrencesOf("Test ab some other abab", "a"));  // 3

memset(buffer, 0, 50);
strcpy(buffer, "   test   ");
printf("Trimmed string: %s\n\n", trimString(buffer));   // test

printf("Is string equals: %s\n", isStringEquals("", "") ? "Yes" : "No");  // Yes
printf("Is string equals: %s\n", isStringEquals("aaB", "aaB") ? "Yes" : "No");  // Yes
printf("Is string not equals: %s\n", isStringNotEquals("a", "") ? "Yes" : "No");  // Yes
printf("Is string not equals: %s\n", isStringNotEquals("a", NULL) ? "Yes" : "No");  // Yes

stringutils's People

Contributors

ximtech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.