Outputstream of http provider breaks utf-8 encoding

I’m trying to serve utf-8 encoded VTT files. Unfortunately HTTPProviderCaptionFile mangles utf-8 VTT files. I don’t think the server supports internationalisation correctly as required for captions.

When trying to write utf-8 text to the output stream it also mangles it. But utf-8 text shows correctly in live sideloaded webvtt. Ive set the startup flags to uft-8 encoding also. How to configure the output stream of the provider to output utf-8 encoding ?

Ive tried Files copy to output to the stream directly but doesnt read as utf-8

public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {

	
	String uriPath = super.getPath(req, false);
	String[] paths = uriPath.split("/"+IApplicationInstance.DEFAULT_APPINSTANCE_NAME+"/");
	String appName = paths[0];
	//String filePath = "${com.wowza.wms.context.VHostConfigHome}/" + paths[1];
	
	
	IApplication app = vhost.getApplication(appName);
	IApplicationInstance appInstance = app.getAppInstance(IApplicationInstance.DEFAULT_APPINSTANCE_NAME);
	
	String filePath = appInstance.getStreamStorageDir() + "/" + paths[1];

	OutputStream out = resp.getOutputStream();
	
	try {
	

	File toBeCopied = new File(filePath);
	//Path path = toBeCopied.toPath();
	
	//Files.copy(toBeCopied, out);
	
	  BufferedReader inf = null;
	    
	  if (toBeCopied.exists())
	  {
	    	//inf = new BufferedReader(new FileReader(textFileObj, ));
	    	 inf = new BufferedReader(
		           new InputStreamReader(new FileInputStream(toBeCopied ), "UTF-8"));
	    	String line;
			while ((line = inf.readLine()) != null)
			{
				//out.write(line.getBytes("UTF-8"));

				out.write(line.getBytes());
				WMSLoggerFactory.getLogger(null).info(line);
			}
	  }
	  

	
	} catch (Exception e) {
		try {
		byte[] outBytes1 = e.getMessage().getBytes();
		out.write(outBytes1);
		} catch (Exception e1) {
			
		}
	}
}

In the wowza log it prints correctly

これは、画面のより多くを占めるはずの、はるかに長い 2 番目のクローズド キャプションです。

In the output it displays like

初めての Wowza Media Server ã‚¯ãƒ­ãƒ¼ã‚ºãƒ‰ã‚­ãƒ£ãƒ—ã‚·ãƒ§ãƒ³ã€‚ã“ã‚Œã¯ã€ç”»é¢ã®ã‚ˆã‚Šå¤šãã‚’å ã‚ã‚‹ã¯ãšã®ã€ã¯ã‚‹ã‹ã«é•·ã„ 2 番目のクローズド キャプションです。3番目のクローズドキャプションはこちら

In the startup flag I have

<VMOption>-Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8</VMOption>

The captionfile module will output the vtt files incorrectly. They display the correct characters when loading the files locally.

00:00:13.000 --> 00:00:14.000 

過去2週間で深刻な

I found changing the content type helped so overriding the default provider seems to be ok I think. But the newlines are messed up.

public class VTTHTTPProviderTest extends HTTPProviderCaptionFile {

public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
	resp.setHeader("Content-Type", "text/html; charset=utf-8");
	super.onHTTPRequest(vhost, req, resp);
	resp.setHeader("Content-Type", "text/html; charset=utf-8");
	
}

}