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

how to change string encoding charset #293

Closed
zhengdi1992 opened this issue Mar 25, 2019 · 4 comments
Closed

how to change string encoding charset #293

zhengdi1992 opened this issue Mar 25, 2019 · 4 comments
Labels

Comments

@zhengdi1992
Copy link

for history reason..i can not change the global setting to change file.encoding=UTF8
maybe i will cause some problem unpredictably..
but now i need to load a .pb file and input is a string tensor..but my app's file encoding default was US-ASCII print by System.out.println(Charset.defaultCharset())

i want to know whether exist api for change the charset encoding in small scope or not?
tensorflow.Tensor mockInput = new tensorflow.Tensor(tensorflow.DT_STRING, new TensorShape(new long[]{1}));
mockInput.createStringArray().put("香蕉 苹果 西瓜");

such as :
mockInput.createStringArray().put("香蕉 苹果 西瓜","UTF-8"); ?

i have try this but not worked.. :(
mockInput.tensor_data().putString("香蕉 苹果 西瓜","UTF-8");

@saudet saudet added the bug label Mar 25, 2019
saudet added a commit to bytedeco/javacpp-presets that referenced this issue Mar 25, 2019
@saudet
Copy link
Member

saudet commented Mar 26, 2019

Oops, sorry about that. I've added a StringArray.putString(BytePointer) method to fix this issue in commit bytedeco/javacpp-presets@5e3bf2a, so we can now do something like:
createStringArray().putString(new BytePointer("香蕉 苹果 西瓜", "UTF-8")).
Please give it a try with the snapshots: http://bytedeco.org/builds/

@zhengdi1992
Copy link
Author

thx. i've see the push to master
and i've use

     <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>tensorflow</artifactId>
        <version>1.5.0-1.4</version>
      </dependency>
      <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>tensorflow</artifactId>
        <version>1.5.0-1.4</version>
        <classifier>macosx-x86_64</classifier>
      </dependency>

was i should change the version to which ?.snapshot

and additionally..
any method for like createStringArray().toString("UTF-8")

@saudet
Copy link
Member

saudet commented Mar 26, 2019

See the version here:
https://github.com/bytedeco/javacpp-presets/tree/master/tensorflow

For the other way around, we can use: data().capacity(size()).getString("UTF-8")

@saudet
Copy link
Member

saudet commented Apr 11, 2019

The changes have now been included with version 1.5. Please let me know if you encounter any other issues and thanks for reporting!

@saudet saudet closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants