New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some text appears garbled when loaded from a project file #488

Closed
claui opened this Issue Dec 4, 2011 · 8 comments

Comments

Projects
None yet
3 participants
@claui
Copy link

claui commented Dec 4, 2011

Issue description

Non-ASCII text content is displayed garbled when loaded from a Gephi project file.

The issue occurs since Project API 0.8.0.1. In fact, it occurred right away after I had updated the Project API plugin from 0.8.0 to 0.8.0.1.

This is reproducible on my Mac and possibly affects other, if not all, OS X systems.

Saving seems to work properly; the issue affects only loading. It does not matter if the project was saved using the last plugin version or the new one.

Steps to reproduce

The issue is 100 % reproducible on my Mac. Just create a new project with a single node labeled

ÄÖÜ

and save. As soon as the project is loaded again, the label says

ÄÖÜ

My guess is that the issue affects systems whose Java runtime does NOT use UTF-8 as its default character encoding (e. g. the Java runtime on Mac OS).
So it might be reproducible on any Mac OS system, possibly even on a few other OSs.

Possible cause

My guess is that the issue might have been introduced with the fix for issue #465.

I have looked at the changes in 8f9dfd5 for a bit. It introduces an intermediate InputStreamReader (see line 103) whose purpose is to filter out certain characters. It is then piped to both the original input stream and the XMLStreamReader.

The original file input stream is not handed directly to the XMLStreamReader anymore. Instead it’s now the InputStreamReader’s duty to decode bytes to characters – and to use the proper character encoding (XMLStreamReader did both before the change).

However, the constructor in line 103 – InputStreamReader(java.io.InputStream) – by specification just asks the Java runtime for the default encoding, which happens to be MacRoman on the Mac.

As far as my guesswork is correct, the actual XML should be UTF-8 … so the InputStreamReader gets incorrect info about the encoding and creates the incorrect characters which it then hands further down to the XMLStreamReader.

Perhaps this could be fixed by just using InputStreamReader(java.io.InputStream, java.nio.charset.Charset) instead, a version of the constructor which takes the character encoding as an argument.

Workaround

The issue went away when I downgraded to version 0.8.0 of the Project API plugin.

See also

Issue #474 (November 15, 2011) mentions a similar problem with GEXF files.

@eduramiba

This comment has been minimized.

Copy link
Member

eduramiba commented Dec 8, 2011

Hi,
Thank you for your help.
I just commited the fix.

@eduramiba eduramiba closed this Dec 8, 2011

@mbastian

This comment has been minimized.

Copy link
Member

mbastian commented Dec 8, 2011

Just saw this bug report. That's a great example of collaboration. Well done!

@eduramiba

This comment has been minimized.

Copy link
Member

eduramiba commented Dec 8, 2011

Yeah, great work claui :D
By the way, I tried to merge with your commit here https://github.com/claui/gephi/commit/92809b370fa4e61a4ff8de1f3d807d2440561d61 but I could not find how to do it with git (because it is not a branch of gephi master). Is it possible?

@mbastian

This comment has been minimized.

Copy link
Member

mbastian commented Dec 8, 2011

I think it would be better to create a pull requests for that. claui could just select which commit to include.

@claui

This comment has been minimized.

Copy link

claui commented Dec 8, 2011

Hi mbastian and eduramiba,

Aww, thanks a lot for the kind words =)

@mbastian:
Thanks for the pointer.
Should I also commit this change

-OpenIDE-Module-Specification-Version: 0.8.0.1
+OpenIDE-Module-Specification-Version: 0.8.0.2

to my fork … before I make the pull request?
I don’t really understand how this merging (magic ^^) works and am a bit anxious that I break something …

@eduramiba

This comment has been minimized.

Copy link
Member

eduramiba commented Dec 8, 2011

Oh, don't worry. You don't have to do anything now.
I was just wondering how to include your changes without rewriting them, and have your authorship visible in the log (this in git is a little different than bazaar).

Maybe I could have pulled it without request and pushed it to master.

@mbastian

This comment has been minimized.

Copy link
Member

mbastian commented Dec 9, 2011

The way to do this is using pull requests (http://help.github.com/send-pull-requests/).

Another way would be the following.

  • Make sure your fork is up to date: git pull upstream master
  • In your fork you add a remote for claui's fork (git remote add claui ...)
  • You run git pull claui master. That should merge claui's commit in your master branch.
  • git push origin master to push to your fork
  • git push origin master to push to main gephi
@eduramiba

This comment has been minimized.

Copy link
Member

eduramiba commented Dec 9, 2011

Thanks, I think I understand now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment