Convert integers to equivalent characters in string - NOT ASCII code character

I have to output my data and associated string information to a string array and then to a spreadsheet file.
I want to do this by converting integers (and other numbers) to an identical string of characters.
I have tried Type Cast with a string constant as the type input but it DOES NOT WORK.  Instead, I get the ASCII character whose numerical designation matches the integer, e.g. integer "50" become capital "P".
I want integer "50" to be string "50".
Please advise and no, I do not want to make arrays of clusters.
Go to Solution.

I found my answer but only after searching for "Number" conversion rather than "Integer" conversions.
In the Programming palette  - String Functions - String/Number Conversion - Number to Decimal String:
"Converts number to a string of decimal digits at least width characters wide or wider if necessary. If number is floating-point, it is rounded to a 64-bit integer before conversion."

Similar Messages

  • Need help with converting characters to ASCII code

    Hey. Im trying to write a program to make Caesar Ciphers by random numbers. This cipher must also wrap from front to end of ASCII code, so that if, for example, the character being ciphered is Z and its being modified by +3, the result ciphered character is not "]", but "c".
    Im planning on reading the text that the user inputs (using ConsoleIO) into a string and then seperating each character into a character[]. Then, i would like to find the ASCII code of each character and print out the ASCII code character of the old ASCII code + the modifier.
    So far, this is what i have (sorry for the length, i like to space things out so that its easier on the eyes and more organized... X-( ... ):
    public class EvanFinalB {
         static ConsoleIO kbd = new ConsoleIO();
         static String enteredPhrase;
         static int phraseLength;
         public static void main(String[] args)
              System.out.println("Enter a phrase and this program will cipher it into a secret message.");
              System.out.println("/nEnter your phrase here:");
              //read phrase
              enteredPhrase = kbd.toString();
              //find length of entered text
              phraseLength = enteredPhrase.length();
              //declare arrays for the individual characters of the entered text and the ciphered characters
              char[] enteredChar = new char[phraseLength + 1];
              char[] cipheredChar = new char[phraseLength + 1];
              //loop converting of entered text into seperate characters
              for(int x = 1; x <= phraseLength; x++)
                   enteredChar[x] = enteredPhrase.charAt(x);
                   cipheredChar[x] = cipher(enteredChar[x]);//call cipher() method to find new ciphered character
         //wrap from front to end of ASCII code
         static char cipher(char enteredChar)
              //choose random number to cipher message by
              int modifier = (int)(Math.random() * 26) + 1;
              if(enteredChar + modifier > 90)//90 is the ASCII code for "Z" which is the last capital letter
                   cipheredChar = (97 + (modifier - (90 - enteredChar)));//97 is the ASCII code for "a" which is the first lower case letter
              return cipheredChar[1];
    }The program is obviously in its early stages but (i started creating it today actually), if there is a simple method or anything that i can use to find the ASCII value of a character in order to use enteredChar so that 'enteredChar' is equal to the ASCII code of the new ciphered character, please help me out...Thanks
    P.S. If there's an easier way to go about creating a program for Caesar Ciphers, let me know.

    The following code is from my Java textbook Big Java by Cay Horstmann. It is not my code and it's just to guide you in your own cipher.
       This class encrypts files using the Caesar cipher.
       For decryption, use an encryptor whose key is the
       negative of the encryption key.
    public class CaesarCipher
          Constructs a cipher object with a given key.
          @param aKey the encryption key
       public CaesarCipher(int aKey)
          key = aKey;
          Encrypts the contents of a stream.
          @param in the input stream
          @param out the output stream
       public void encryptStream(InputStream in, OutputStream out)
             throws IOException
          boolean done = false;
          while (!done)
             int next =;
             if (next == -1) done = true;
                byte b = (byte) next;
                byte c = encrypt(b);
          Encrypts a byte.
          @param b the byte to encrypt
          @return the encrypted byte
       public byte encrypt(byte b)
          return (byte) (b + key);
       private int key;
    import java.util.Scanner;
       This program encrypts a file, using the Caesar cipher.
    public class CaesarEncryptor
       public static void main(String[] args)
          Scanner in = new Scanner(;
             System.out.print("Input file: ");
             String inFile =;
             System.out.print("Output file: ");
             String outFile =;
             System.out.print("Encryption key: ");
             int key = in.nextInt();
             InputStream inStream = new FileInputStream(inFile);
             OutputStream outStream = new FileOutputStream(outFile);
             CaesarCipher cipher = new CaesarCipher(key);
             cipher.encryptStream(inStream, outStream);
          catch (IOException exception)
             System.out.println("Error processing file: " + exception);

  • I need a java function that convert string to ASCII,

    I have a string like "test123"
    I want to convert this string to ascii code?how could I do this

    It is not compeltely clear, what you need, but String has this method:
    public byte[] getBytes(String charsetName)  throws UnsupportedEncodingException

  • Convertion to ASCII code

    Hi everybody,
    I have string:s, I convert it to an integer in base 16:
    int a = 0;
    a = Integer.parseInt(s, 16);
    How can I convert the integer: a to it's equvalence ASCII code?
    Any help is greatly appreciated.

    I think we'lll try that again;-
    char c = (char)a;Without other info, and based solely on 'ascii' the following is probably better...
          if (a > 127)
              throw new Exception("Can not map value(" + a + ") to ascii");
          char c = (char)a;

  • How can i convert values in my string to ascii characters

    Hi guy.
    I am wrinting a code but i m stuck, I have a string with (Battle of Midway) in it, Now i want to convert each character in this string with the asci character,,,
    String temp = {"Battle of Midway"};
    so the ascii will be:
    B=66 a=97 t=116 l=108 e=101 o=111 f=102 M=77 i=105 d=100 w=119 y=121
    i found all these number for all the charachers, but i donno how to covert this string into ascii characerts... ofcurse i can do it one by one...but is there any class or method i can use for this,,,,, Once i convert all the character (from string) to ascii character THEN i have to convert it back from ascii to character,,
    Is anybody has any idea
    Thanks alot in Advance

    You get get the ascii code for those characters by doing something like:
    int ascii = str.charAt(0); //Get ascii value for the first character.

  • Convert web page to adobe pdf can not convert greek characters

    Convert web page to adobe pdf can not convert greek characters. How to solve it?

    Convert web page to adobe pdf can not convert greek characters. How to solve it?

  • Characters from VISA not in ascii

    I am using ARM Cortex Microcontroller. I am sending the numbers into lab view through usb port.
    In such case, the strings obtained from VISA Read are not ascii but i can convert them into unsigned int with the help of string to uint premitive.
    The numbers to be sent are continuous and they consist of u8, u16 and also float values.
    So the problem here is the conversion. only those value which are defined as u8 are displayed correctly.
    How do i convert into appropriate values.
    E.g. if the value is integer but greater than 255 i should be able to read and display.
    If the value is float i should be able to display the proper float number.
    I also tried with scan string premitive, also string to number premitive. They can only read ascii and convert, but the characters i am converting are not ascii.
    The characters i am receiving look like boxes and for a value of 0 they are empty space.
    To convert a number into ASCII in my microcontroller could also be possible but the requirement here is with lab view. Microcontroller currently has huge load of programs.
    I would be happy if someone whould help me in this.
    Thanks in advance.
    Go to Solution.

    Sorry for the mistake to write it is string to byte.
    The necessary clippings are as below. The second clipping 'read buffer' is from a series of transformation where, first data is 300, second is 1 and third is 1.23. The output for these as seen in the third picture is 44, 1 and 1. Yes, 300-256 = 44, previously i wrote 45.
    According to you, do you mean that the first two byte should correspond to 300 ? and also similar for the float (not only one byte value but with several values in consecutive elements of the array)?
    I would be happy if similar clips would be avialable.

  • How to accept only 4 or less hex characters in string control

    I want to accept only up to 4 hex characters in a string control. I dont want to use "hex display" property.
    How is it possible? I have String control key down? event in event case, I tried it with regular expressions [0-9a-fA-F]{4} but then I have to accept left, right, delete, backspace, home keys as well.
    Go to Solution.

    I agree with Dennis that you seem to be making life difficult for yourself.  However, you did ask the equivalent (as I understand it) "How can I allow the user to type "1", "2", "Ctrl-A", "B", "Ctrl-C", "D" and get this recognized as the string "12BD".  If you really want to do this, here is one way (I was lazy and left the answer as an array of 4 1-character strings).  I use PlatMods to exclude having any "modification" key other than Shift down, convert the numeric Char into a string, then count acceptable Hex letters and conditionally add them to the output array, stopping when I have 4 characters. 
    Bob Schor

  • Converting a Labview time into a string with Measurement Studio C++

    In my Measurement Studio-based C++ application, I'll be sent a Labview
    time in the format of a double, which I believe is seconds since 1904.
    Does Measurement Studio for Visual C++ contain a function that will
    convert that time value into a string format? I'd like to end up with
    something like "hh:mm:ss:msec". I'm basically looking for the
    equivalent of the Labview vi, "Format Time/Date String". If Measurement
    Studio doesn't provide this, is there some other (hopefully simple) way
    to do this?
    I can request that the Labview application send me time in a string
    format as well as a double; this will require several changes to the
    Labview application sending the timestamp, but if that is a simpler
    solution that's the option we'll take.
    Thanks in advance,

    Measurement Studio does not have a function for this, but you can do
    this yourself by first converting from LV epoch (1/1/1904) to Unix
    epoch(1/1/1970) and then using c runtime time functions
    UNIXEpochOffset is the difference between the 2 epochs at GMT. To
    convert to a UNIX system clock value, just subtract the sum of this
    number and your time zone offset in seconds
    lvTime is the value returned by LV timestamp
    #define  UNIXEpochOffset 2082844800
    int _tmain(int argc, _TCHAR* argv[])
        __int64 lvTime = 3214396284; //10:48:13.173 AM 11/9/2005
        //GMT offset for Central Time is -6 (3600 seconds). You will need to account for daylight savings time.
        int offset = -3600;
        time_t unixTime = lvTime - UNIXEpochOffset - offset;  
        struct tm *newtime = localtime(&unixTime);
        printf(asctime( newtime )); //prints out the time in a string format.
        return 0;
    Bilal Durrani

  • How can I convert the variable expression stored as string back to variable expression

    How can I convert the variable expression stored as string back to variable expression?
    I am storing the expression enterd in the TSExpresssionEditControl as simple string and want to convert back to expression since I want to get the data type of that expression.

    I'm not sure what you're trying to do exactly. If you are trying to get the value of a variable and you only have the name of value in a string, then you can use Evaluate() to get its value. If you want the data type, my advise is to use the GetPropertyObject() API method and just pass in the loop up string. Then you'll have a handle to the data object and then proceed from there.
    Song D
    Application Engineer
    National Instrument
    Song Du
    Systems Software
    National Instruments R&D

  • Converting hexadecimal XML data to a string

    Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
    After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
    ASSIGN <line> TO <line_c> CASTING.
    After the inftroduction of unicode in our system I get a error:
    In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
    When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
    What does it mean? Does somebody have a solution.
    I need this function for sending this XML data as string over a simple old CPIC connection.
    Best regards

    Hello Martin
    Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
    *& Thread: Converting hexadecimal XML data to a string
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
    REPORT  zus_sdn_xml_xstring_to_string.
    *-- data
    *-- read the XML document from the frontend machine
    TYPES: BEGIN OF xml_line,
            data(256) TYPE x,
          END OF xml_line.
    DATA: xml_table TYPE TABLE OF xml_line.
    DATA: go_xml_doc       TYPE REF TO cl_xml_document,
          gd_xml_string    TYPE string,
          gd_rc            TYPE i.
      p_file  TYPE localfile  DEFAULT 'C:payload_idoc.xml'.
      CREATE OBJECT go_xml_doc.
      " Load XML file from PC and get XML itab
      CALL METHOD go_xml_doc->import_from_file
          filename = p_file
          retcode  = gd_rc.
      CALL METHOD go_xml_doc->get_as_table
          table   = xml_table
    *      size    =
    *      retcode =
    " NOTE: simulate creation of XML itab
      go_xml_doc->display( ).
      create object go_xml_doc.
      CALL METHOD go_xml_doc->parse_table
          table   = xml_table
    *      size    = 0
          retcode = gd_rc.
      CALL METHOD go_xml_doc->render_2_string
    *    EXPORTING
    *      pretty_print = 'X'
          retcode      = gd_rc
          stream       = gd_xml_string
    *      size         =
      write: / gd_xml_string.

  • Number to fractional string not working correctly

    I am measuring some parameters from oscillsocpe. i need to write these values to text file for which i am using write to spreadsheet, but what is happening is it is always writing zero value to file, on debugging i found that while converting from number to string it is always writng zero to string indicator, then separately i used that number to fractional string indicator and it is always showing zero in string output , i dont why it is happening.
    Attached below is the code.
    Go to Solution.
    Time meas ‏31 KB

    Ranjeet Singh and Norbert_B
    Thanks for ther reply
    Ranjeet singh,
    number to fractional string is working correctly, there is some other problem, because inly when i am executing this code converting this rise time value to string then only it is showing zero, otherwise for any random number if i am checking this number to fractional string is working correctly.
    i dont need to convert it back to string that i am doing only to check why it is showing zero value on converting number to string , because when i was writing to spreadsheet file it was always writing zero value, so when checked that code it was observed that while converting from array of numbers to spreadsheet string it is always writing zero value that's why i am doing it here just to check why it is not converting to string, but your suggestion helped in focussing the string that i am gettong from VISA read, i can use that  in last case if i wont be able to find the solution but main problem is that why i am not able to convert it back to string, why it is showing zero because it is because of this only write to spreadsheet is always showing zero value .

  • Removing non-numeric characters from string

    Hi there,
    I need to have the ability to remove non-numeric characters from a string and I do not know how to do this.
    Does any one know a way?
    Present String: (02)-2345-4607
    Required String: 0223454607
    Thanks in advance

    Dear NickM
    Try this this will work...........
    create or replace function char2num(mstring in varchar2) return integer
    -- Function to remove Special characters and alphebets from phone no. string field
    -- Author - Valid Bharde.(India-Mumbai)
    -- Date :- 20 Sept 2006.
    -- This Function will return numeric representation.
    -- The Folowing program is gifted to NickM with respect to his post on oracle site regarding Removing non-numeric characters from string on the said date
    mstatus number :=0;
    mnum number:=0;
    mrefstring varchar2(50);
    mnum := length(mstring);
    for x in 1..mnum loop
    if (ASCII(substr(upper(mstring),x,1)) >= 48 and ASCII(substr(upper(mstring),x,1)) <= 57) then
    mrefstring := mrefstring || substr(mstring,x,1);
    end if;
    end loop;
    return mrefstring;
    copy the above program and use it at function for example
    SQL> select char2num('(022)-453452781') from dual;

  • Cannot convert between unicode and non-unicode string datatypes

      My source is having 3 fields :
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    My destination is : 
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    But still I am getting this error : 
    Column ItemCode cannot convert between unicode and non-unicode string datatypes.
    As I am new to SSIS , please show me step by step.
    Thanks In Advance.

      My source is having 3 fields :
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    My destination is : 
    ItemCode nvarchar(50)
    DivisionCode nvarchar(50)
    Salesplan (float)
    But still I am getting this error : 
    Column ItemCode cannot convert between unicode and non-unicode string datatypes.
    As I am new to SSIS , please show me step by step.
    Thanks In Advance.
    HI Subu ,
    there is some information gap , what is your source ? are there any transformation in between ?
    If its SQL server source and destination and the datatype is as you have mentioned I dont think you should be getting such errors ... to be sure check advance properties of your source and check metada of your source columns
    just check simple oledb source as
    SELECT TOP 1 ItemCode = cast('111' as nvarchar(50)),DivisionCode = cast('222' AS nvarchar(50)), Salesplan = cast(3.3 As float) FROM sys.sysobjects
    and destination as you mentioned ... it should work ...
    somewher in your package the source columns metadata is not right .. and you need to convert it or fix the source.
    Hope that helps
    -- Kunal
    Hope that helps ... Kunal

  • How to convert character string into ascii format correctly

    dear all
    I'm using encryption technique in my application(oracle formas 6i). character stream convert to the ascii format and add some numeric value and again convert to the character format
    here I'm using ASCII and CHR functions.
    .net program also using same algorithm to encrypt this password.....finally both the character strings are not equel.(This happens if the character string's ascii value greater than 127. otherwise both are equel).
    pls give me a solution for this
    thanks and regards

    hir dear
    do u want to encrypt & dcrypt your password.which version of oracle you are using
    first store these procedure in Oracle Databases: dbms_obfuscation_toolkit, dbms_crypto, Transparent Data Encryption
    now u can use these procedure to encrypt & dcrypt your password
    if you any query about those procedures you can ask me
    best regard

Maybe you are looking for

  • Steps to create LOGICAL DATABASE in sap

    hi guys, i have gone through many documents about LDB. But, i didnt get the steps to create a LDB. plz provide me with the steps to be followed to create a LDB. thnx, shivaa.

  • Another circle applet question

    I am wondering, how do I keep track of user clicks so that I can have the program set the location of the circle for the first click and then draw the radius with the second click? Here is what I got so far. import java.applet.Applet; import java.awt

  • Future Planning; How do I get connected? (Frustrate​d and irritated.​)

    I am posting on this forum to hopefully get any information and assistance I possibly can regarding getting DSL service at my house. First, a little background info. I live less than 30 miles outside of Richmond, VA; a major metropolitan area that is

  • WebCenter Content and BPM

    Hi, I have installed UCM and SOA BPM. Now I need to integrate this products. Can somebody advice me how to do this? Thanks!

  • Webi/Report : Schedule : Destination configuration

    In the Report : Schedule : Destination of Webi, is it possible to disable the "Use the Job Server's defaults" check box in ?