Skip to content
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

Override file encoding #30

Closed
dernst opened this issue Jul 6, 2018 · 1 comment
Closed

Override file encoding #30

dernst opened this issue Jul 6, 2018 · 1 comment

Comments

@dernst
Copy link

dernst commented Jul 6, 2018

Firstly, thanks for making this software freely available 👍
I was trying to read a SAS file with UTF-8 strings but whose metadata however claims to be in windows-1252.

I thought I could override this setting by using
SasFileReaderImpl sasFileReader = new SasFileReaderImpl(fis, "UTF-8");

which didn't work though:

Field f = sasFileReader.getClass().getDeclaredField("sasFileParser");
f.setAccessible(true);
SasFileParser sfp = (SasFileParser) f.get(sasFileReader);

f = sfp.getClass().getDeclaredField("encoding");
f.setAccessible(true);
String enc = (String)f.get(sfp);
System.out.println(enc);  // would still output windows-1252

setting the encoding via reflection ultimately did produce the correct (afaics) results. Is this intended behaviour and if so would you think it migh be beneficial to add an option to allow overriding the charset settings from the file's metadata?

@Yana-Guseva
Copy link
Collaborator

Hi @dernst , thanks for reporting this issue. Currently, the problem with setting the encoding is fixed in the master branch, and it will be included in the next release. You can override the encoding settings from the file's metadata when creating an instance of the SasFileReaderImpl class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants