private void checkString(PsiElement node, String value) {
      if (LanguageLevel.forElement(node).isPython2()) {
        PsiFile file = node.getContainingFile(); // can't cache this in the instance, alas
        if (file == null) return;
        final String charsetString = PythonFileType.getCharsetFromEncodingDeclaration(file);

        boolean hasNonAscii = false;

        CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder();
        int length = value.length();
        char c = 0;
        for (int i = 0; i < length; ++i) {
          c = value.charAt(i);
          if (!asciiEncoder.canEncode(c)) {
            hasNonAscii = true;
            break;
          }
        }

        if (hasNonAscii) {
          if (charsetString == null) {
            registerProblem(node, PyPsiBundle.message("INSP.non.ascii.char.non.ascii.character.in.file.but.no.encoding.declared", c),
                            new AddEncodingQuickFix(myDefaultEncoding, myEncodingFormatIndex));
          }
        }
      }
    }
private void checkString(PsiElement node, String value)