Storing an String for LCD with custom characters

Hello,

I would like to clean up my code by creating a string in the beginning and simply printing that string throughout the code. I hope that it will operate a little quicker that way and just provide some housecleaning.

Right now, I am using the following code to generate a Left/Right type bar graph that resembles a different "level".

//Creating Custom Char (5)

  uint8_t bar0[8]  = {
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; 
  uint8_t bar5[8]  = {
    0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};


void setup(){

  lcd.createChar(0, bar0);
  lcd.createChar(5, bar5);

}

void loop(){

If (my variable == my conditions for level3){
          lcd.print("<   [^]");
          lcd.write(5);
          lcd.write(5);
          lcd.write(5);
          lcd.print(">     ");
        
          level = -3;
}

This is roughly what I would like to do, but am not sure how to get that done with the string and custom character.

//Creating Custom Char (5)

  uint8_t bar0[8]  = {
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; 
  uint8_t bar5[8]  = {
    0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};


void setup(){

  lcd.createChar(0, bar0);
  lcd.createChar(5, bar5);


//Creating Levels
String level2 = "";
	level2 += ("<   [^]");
	level2 += (5);
	level2 += (5);
	level2 += (" >    ");

String level3 = "";
          level3 += ("<   [^]");
          level3 += (5);
          level3 += (5);
          level3 += (5);
          level3 += (">     ");
	

}

void loop(){

If (my variable == my conditions for level3){

	lcd.print(level3);

}

Is that something that can be done?

Is that something that can be done?

No. You can't mix text and binary data in a string or a String.

PaulS:
No. You can't mix text and binary data in a string or a String.

Objection.

You can not easily use strings with embedded zero bytes,
as they would be interpreted as end of string by most string functions,
other control characters are perfectly legal (most often used are '\n' '\r').

Using

char buff[] = { 1, 2, 3, 'A', 'B', 0 };
// or
char buff[] = "\1\2\3AB";

works.

Agree with Whandall. Don't use character 0 definition as you will need to specially handle it if you want to embed it in a string. Starting at ASCII 1 makes it possible to use '\0' terminated strings.

Thank you all for the input!