Skip to content

Commit

Permalink
Merge pull request #1 from andreymukha/cyrillic_symbols
Browse files Browse the repository at this point in the history
fix issue johna1203#17
  • Loading branch information
andreymukha committed Dec 16, 2015
2 parents 7dc4555 + b0fff6b commit cb99c26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/com/kodokux/github/GithubGetGistAction.java
Expand Up @@ -23,13 +23,12 @@
import com.kodokux.github.util.GetGistSettings;
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.github.util.GithubAuthDataHolder;
import org.jetbrains.plugins.github.util.GithubSettings;
import org.jetbrains.plugins.github.util.GithubUtil;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -75,6 +74,12 @@ public void consume(JsonElement jsonElement) {
if (jsonElement != null) {
for (JsonElement jsonElement1 : jsonElement.getAsJsonArray()) {
String name = jsonElement1.getAsJsonObject().get("description").getAsString();
try {
byte b[] = name.getBytes("Windows-1251");
name = new String(b, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
DefaultMutableTreeNode node = new DefaultMutableTreeNode(name);
root.add(node);
if (jsonElement1.getAsJsonObject().has("files")) {
Expand Down
8 changes: 7 additions & 1 deletion src/com/kodokux/github/ui/GithubGetGistToolWindowView.java
Expand Up @@ -33,7 +33,6 @@
import com.intellij.ui.treeStructure.Tree;
import com.kodokux.github.EditorManager;
import com.kodokux.github.GitHubGistFileTreeNode;
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
Expand All @@ -48,6 +47,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;

Expand Down Expand Up @@ -251,6 +251,12 @@ public void onSuccess() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
byte[] b = fileSource.getBytes("Windows-1251");
fileSource = new String(b, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
getEditor().getDocument().setText(fileSource);
//GithubGetGistCache.setCache(project, fileNode.getFilename(), fileSource);
}
Expand Down

1 comment on commit cb99c26

@Kontrael
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет. Подскажи, пожалуйста, у тебя баг с кодировкой не вернулся?
Установил твою версию плагина и вот: https://yadi.sk/i/jdpAK_n-3JhZP8

Please sign in to comment.