all groups > vj# > august 2004 >
You're in the

vj#

group:

Equivalent of String.fromCharCode() method in J#


Equivalent of String.fromCharCode() method in J# Bob
8/18/2004 5:28:05 PM
vj#: In Jscript, fromCharCode returns a string from a number of
Unicode character values.
In the following example, test contains the string "plain":

var test = String.fromCharCode(112, 108, 97, 105, 110);

Does anyone know the equivalent of this method in J#?

Thanks,
Bob
Re: Equivalent of String.fromCharCode() method in J# Lars-Inge Tønnessen [VJ# MVP]
8/21/2004 9:57:47 PM

I just made something... =:o)


public class J_String
{
public J_String( )
{
}

public String fromCharCode( int[] var )
{
String result = new String("");
for ( int counter = 0; counter < var.length; counter++ )
result = result.Concat( result+""+(char)var[counter] );
return result;
}
}


public class Class1
{
public Class1()
{
J_String f = new J_String();
System.out.println("->"+f.fromCharCode(new int[] {112, 108, 97, 105,
110})+"<-");
}

/** @attribute System.STAThread() */
public static void main(String[] args)
{
new Class1();
}
}



Regards,
Lars-Inge Tønnessen
www.larsinge.com

Re: Equivalent of String.fromCharCode() method in J# Lars-Inge Tønnessen [VJ# MVP]
8/21/2004 10:05:56 PM

Here is a second solution:


char[] numb = {112, 108, 97, 105, 110};
System.out.println("->"+String.copyValueOf(numb)+"<-" );


Regards,
Lars-Inge Tønnessen
www.larsinge.com

AddThis Social Bookmark Button