resources/src/main/java/org/robolectric/res/StringResources.java
@VisibleForTesting
  static String escape(String text) {
    // unwrap double quotes
    if (text.length() > 1 && text.charAt(0) == '"' && text.charAt(text.length() - 1) == '"') {
      text = text.substring(1, text.length() - 1);
    }
    int i = 0;
    int length = text.length();
    StringBuilder result = new StringBuilder(text.length());
    while (true) {
      int j = text.indexOf('\\', i);
      if (j == -1) {
        result.append(removeUnescapedDoubleQuotes(text.substring(i)));
        break;
      }
      result.append(removeUnescapedDoubleQuotes(text.substring(i, j)));
      if (j == length - 1) {
        // dangling backslash
        break;
      }
      boolean isUnicodeEscape = false;
      char escapeCode = text.charAt(j + 1);
      switch (escapeCode) {
        case '\'':
        case '"':
        case '\\':
        case '?':
        case '@':
        case '#':
          result.append(escapeCode);
          break;
        case 'n':
          result.append('\n');
          break;
        case 't':
          result.append('\t');
          break;
        case 'u':
          isUnicodeEscape = true;
          break;
        default:
          Logger.strict("Unsupported string resource escape code '%s'", escapeCode);
      }
      if (!isUnicodeEscape) {
        i = j + 2;
      } else {
        j += 2;
        if (length - j < CODE_POINT_LENGTH) {
          throw new IllegalArgumentException("Too short code point: \\u" + text.substring(j));
        }
        String codePoint = text.substring(j, j + CODE_POINT_LENGTH);
        result.append(extractCodePoint(codePoint));
        i = j + CODE_POINT_LENGTH;
      }
    }
    return result.toString();
  }
@VisibleForTesting
  static String escape(String text) {
    // unwrap double quotes
    if (text.length() > 1 && text.charAt(0) == '"' && text.charAt(text.length() - 1) == '"') {
      text = text.substring(1, text.length() - 1);
    }
    int i = 0;
    int length = text.length();
    StringBuilder result = new StringBuilder(text.length());
    while (true) {
      int j = text.indexOf('\\', i);
      if (j == -1) {
        result.append(removeUnescapedDoubleQuotes(text.substring(i)));
        break;
      }
      result.append(removeUnescapedDoubleQuotes(text.substring(i, j)));
      if (j == length - 1) {
        // dangling backslash
        break;
      }
      boolean isUnicodeEscape = false;
      char escapeCode = text.charAt(j + 1);
      switch (escapeCode) {
        case '\'':
        case '"':
        case '\\':
        case '?':
        case '@':
        case '#':
          result.append(escapeCode);
          break;
        case 'n':
          result.append('\n');
          break;
        case 't':
          result.append('\t');
          break;
        case 'u':
          isUnicodeEscape = true;
          break;
        default:
          Logger.strict("Unsupported string resource escape code '%s'", escapeCode);
      }
      if (!isUnicodeEscape) {
        i = j + 2;
      } else {
        j += 2;
        if (length - j < CODE_POINT_LENGTH) {
          throw new IllegalArgumentException("Too short code point: \\u" + text.substring(j));
        }
        String codePoint = text.substring(j, j + CODE_POINT_LENGTH);
        result.append(extractCodePoint(codePoint));
        i = j + CODE_POINT_LENGTH;
      }
    }
    return result.toString();
  }
Provides escaping of String resources as described
[here](http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling).

@param text Text to escape.
@return Escaped text.