void (@NotNull StringBuilder builder, @NotNull String stringText, char originalQuote) { char targetQuote = PyStringLiteralUtil.flipQuote(originalQuote); char[] charArr = stringText.toCharArray(); int i = 0; while (i != charArr.length) { char ch1 = charArr[i]; char ch2 = i + 1 < charArr.length ? charArr[i + 1] : '\0'; if (ch1 == originalQuote) { builder.append(targetQuote); } else if (ch1 == targetQuote) { builder.append("\\").append(targetQuote); } else if (ch1 == '\\') { if (ch2 == originalQuote) { builder.append(ch2); i++; } else if (ch2 == '\0') { builder.append(ch1); } else { builder.append(ch1).append(ch2); i++; } } else { builder.append(ch1); } i++; } }