Converting string to char array

Hi,

I have a string that I need to convert to a char array to pass to a Java
object, so if I do this manually I have to do:

exampleVar = javaCast(“char”, [‘e’,‘x’,‘a’,‘m’,‘p’,‘l’,‘e’]);

However I have the data as a string:

exampleVar = “example”;

I’ve looked over the functions on the luceedocs.org but I can’t see one for
converting the string to an array, am I missing it or will I have to write
a function myself to do this?

So I’m guessing I’m hoping for something like:

exampleVar = “example”;
exampleStringArray = stringToArray(exampleVar);
exampleCharArray = javaCast(“char”, exampleStringArray);

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon
mso http://www.mso.net - Lucee http://lucee.org - Member

If - for some reason - you wanted to stick with CML:

cfmlArray = exampleVar.listToArray("")

But use the toCharArray() version, IMO–
Adam

On Wednesday, 15 April 2015 00:04:33 UTC+1, Adam Cameron wrote:

You don’t need a special Lucee function; there’s already one in
java.lang.String:

exampleVar = “example”
charArray = exampleVar.toCharArray()
dump(variables)


Adam

On Tuesday, 14 April 2015 23:55:31 UTC+1, Andrew Dixon wrote:

Hi,

I have a string that I need to convert to a char array to pass to a Java
object, so if I do this manually I have to do:

You don’t need a special Lucee function; there’s already one in
java.lang.String:

exampleVar = “example”
charArray = exampleVar.toCharArray()
dump(variables)–
Adam

On Tuesday, 14 April 2015 23:55:31 UTC+1, Andrew Dixon wrote:

Hi,

I have a string that I need to convert to a char array to pass to a Java
object, so if I do this manually I have to do:

as Adam said, we could also extend the function JavaCast to support this
carr = javaCast(“char”, “Hello World”);
can you raise a ticket for it

MichaOn Wed, Apr 15, 2015 at 12:55 AM, Andrew Dixon <@Andrew_Dixon> wrote:

Hi,

I have a string that I need to convert to a char array to pass to a Java
object, so if I do this manually I have to do:

exampleVar = javaCast(“char”, [‘e’,‘x’,‘a’,‘m’,‘p’,‘l’,‘e’]);

However I have the data as a string:

exampleVar = “example”;

I’ve looked over the functions on the luceedocs.org but I can’t see one
for converting the string to an array, am I missing it or will I have to
write a function myself to do this?

So I’m guessing I’m hoping for something like:

exampleVar = “example”;
exampleStringArray = stringToArray(exampleVar);
exampleCharArray = javaCast(“char”, exampleStringArray);

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon
mso http://www.mso.net - Lucee http://lucee.org - Member


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG1WijWf7GAx0zdaDO5x-BXv%3Dh16MoZHQk_aRN7VnCZL08HJ8w%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG1WijWf7GAx0zdaDO5x-BXv%3Dh16MoZHQk_aRN7VnCZL08HJ8w%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.