Java Code Examples for com.strobel.decompiler.PlainTextOutput#setUnicodeOutputEnabled()

The following examples show how to use com.strobel.decompiler.PlainTextOutput#setUnicodeOutputEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Luyten   File: OpenFile.java    License: Apache License 2.0 5 votes vote down vote up
private void decompileWithoutLinks() {
	this.invalidateContent();
	isNavigationLinksValid = false;
	textArea.setHyperlinksEnabled(false);

	StringWriter stringwriter = new StringWriter();
	PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter);
	plainTextOutput.setUnicodeOutputEnabled(decompilationOptions.getSettings().isUnicodeOutputEnabled());
	settings.getLanguage().decompileType(type, plainTextOutput, decompilationOptions);
	setContentPreserveLastScrollPosition(stringwriter.toString());
	this.isContentValid = true;
}
 
Example 2
Source Project: Luyten   File: FileSaver.java    License: Apache License 2.0 5 votes vote down vote up
private void doSaveClassDecompiled(File inFile, File outFile) throws Exception {
	DecompilerSettings settings = cloneSettings();
	LuytenTypeLoader typeLoader = new LuytenTypeLoader();
	MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
	TypeReference type = metadataSystem.lookupType(inFile.getCanonicalPath());

	DecompilationOptions decompilationOptions = new DecompilationOptions();
	decompilationOptions.setSettings(settings);
	decompilationOptions.setFullDecompilation(true);

	boolean isUnicodeEnabled = decompilationOptions.getSettings().isUnicodeOutputEnabled();
	TypeDefinition resolvedType = null;
	if (type == null || ((resolvedType = type.resolve()) == null)) {
		throw new Exception("Unable to resolve type.");
	}
	StringWriter stringwriter = new StringWriter();
	PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter);
	plainTextOutput.setUnicodeOutputEnabled(isUnicodeEnabled);
	settings.getLanguage().decompileType(resolvedType, plainTextOutput, decompilationOptions);
	String decompiledSource = stringwriter.toString();

	System.out.println("[SaveAll]: " + inFile.getName() + " -> " + outFile.getName());
	try (FileOutputStream fos = new FileOutputStream(outFile);
			OutputStreamWriter writer = isUnicodeEnabled ? new OutputStreamWriter(fos, "UTF-8")
					: new OutputStreamWriter(fos);
			BufferedWriter bw = new BufferedWriter(writer);) {
		bw.write(decompiledSource);
		bw.flush();
	}
}