Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5028 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi all

For now I've managed to encode a text field as UTF-8 and write it to a text file, however, what I really need to do is to encode the text on-the-fly, before encoding it as Base64 and sending it to a web service.

I found this script on the web but don't know Java so please tell me what are the variables here so I can declare them before using EvaluateGroovy ():

import java.nio.ByteBuffer;

import java.nio.charset.Charset;

public class MainClass {

public static void print(ByteBuffer bb) {

while (bb.hasRemaining())

System.out.print(bb.get() + " ");

System.out.println();

bb.rewind();

}

public static void main(String[] args) {

ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte) 'a' });

System.out.println("Initial Byte Buffer");

print(bb);

Charset csets = Charset.forName("UTF-8");

System.out.println(csets.name() + ":");

print(csets.encode(bb.asCharBuffer()));

csets.decode(bb);

bb.rewind();

}

}

/*

*/

It seems that the only variable is "bb" but I need some confirmation.

Hope you can help me.

Thanks a lot in advance.

Ibrahim.

This topic is 5028 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.