private DataURIScheme build(String mediaTypeString, String isBase64, String dataString) {
        byte[] data = null;
        //strip out back slashes as you might have in css
        dataString = (dataString != null) ? dataString.replaceAll("\\\\", " ") : dataString;

        if (dataString == null || dataString.isEmpty()) {
            data = new byte[0];
        } else if (isBase64 != null) {
            data = base64.decode(dataString);
        } else {
            //TODO: handle encodings
            MediaType mediaType = MediaType.parse(mediaTypeString);
            Charset charset = StandardCharsets.UTF_8;
            if (mediaType.hasParameters()) {
                String charsetName = mediaType.getParameters().get("charset");
                if (charsetName != null && Charset.isSupported(charsetName)) {
                    try {
                        charset = Charset.forName(charsetName);
                    } catch (IllegalCharsetNameException e) {
                        //swallow and default to UTF-8
                    }
                }
            }
            data = dataString.getBytes(charset);
        }
        return new DataURIScheme(mediaTypeString, (isBase64 != null), data);
    }
Not thread safe.  Create a separate util for each thread.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/DataURISchemeUtil.java