use of java.nio.charset.Charset in project intellij-community by JetBrains.
the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.
//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
cd(myRepository);
String fileName = "file.txt";
echo(fileName, "lalala");
Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
String comment = "öäüß";
HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
commitCommand.executeInCurrentThread();
HgLogCommand logCommand = new HgLogCommand(myProject);
myRepository.refresh(false, true);
VirtualFile file = myRepository.findChild(fileName);
assert file != null;
List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
HgFileRevision rev = revisions.get(0);
assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
use of java.nio.charset.Charset in project intellij-community by JetBrains.
the class PythonDebugConsoleCommunication method execInterpreter.
public void execInterpreter(ConsoleCodeFragment code, final Function<InterpreterResponse, Object> callback) {
if (waitingForInput) {
final OutputStream processInput = myDebugProcess.getProcessHandler().getProcessInput();
if (processInput != null) {
try {
final Charset defaultCharset = EncodingProjectManager.getInstance(myDebugProcess.getProject()).getDefaultCharset();
processInput.write((code.getText()).getBytes(defaultCharset));
processInput.flush();
} catch (IOException e) {
LOG.error(e.getMessage());
}
}
myNeedsMore = false;
waitingForInput = false;
notifyCommandExecuted(waitingForInput);
} else {
exec(new ConsoleCodeFragment(code.getText(), false), new PyDebugCallback<Pair<String, Boolean>>() {
@Override
public void ok(Pair<String, Boolean> executed) {
boolean more = executed.second;
myNeedsMore = more;
notifyCommandExecuted(more);
callback.fun(new InterpreterResponse(more, isWaitingForInput()));
}
@Override
public void error(PyDebuggerException exception) {
myNeedsMore = false;
notifyCommandExecuted(false);
callback.fun(new InterpreterResponse(false, isWaitingForInput()));
}
});
}
}
use of java.nio.charset.Charset in project intellij-community by JetBrains.
the class PydevConsoleRunner method setCorrectStdOutEncoding.
/**
* Set command line charset as current project charset.
* Add required ENV var to Python task to set its stdout charset to current project charset to allow it print correctly.
*
* @param commandLine command line
* @param project current project
*/
static void setCorrectStdOutEncoding(@NotNull GeneralCommandLine commandLine, @NotNull Project project) {
final Charset defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
commandLine.setCharset(defaultCharset);
setPythonIOEncoding(commandLine.getEnvironment(), defaultCharset.name());
}
use of java.nio.charset.Charset in project intellij-community by JetBrains.
the class PydevConsoleRunner method setCorrectStdOutEncoding.
/**
* Add required ENV var to Python task to set its stdout charset to current project charset to allow it print correctly.
*
* @param envs map of envs to add variable
* @param project current project
*/
static void setCorrectStdOutEncoding(@NotNull Map<String, String> envs, @NotNull Project project) {
final Charset defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
final String encoding = defaultCharset.name();
setPythonIOEncoding(setPythonUnbuffered(envs), encoding);
}
use of java.nio.charset.Charset in project voltdb by VoltDB.
the class CharsetUtil method decoder.
/**
* Returns a cached thread-local {@link CharsetDecoder} for the specified {@link Charset}.
*
* @param charset The specified charset
* @return The decoder for the specified <code>charset</code>
*/
public static CharsetDecoder decoder(Charset charset) {
checkNotNull(charset, "charset");
Map<Charset, CharsetDecoder> map = InternalThreadLocalMap.get().charsetDecoderCache();
CharsetDecoder d = map.get(charset);
if (d != null) {
d.reset().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
return d;
}
d = decoder(charset, CodingErrorAction.REPLACE, CodingErrorAction.REPLACE);
map.put(charset, d);
return d;
}
Aggregations