Comparing characters

I'm trying to make a program that will have the user enter a string of code, and then compare the first and last characters of the string to each other
     String text=reader.readLine("Enter string of text ");
          System.out.println(text.length());
          int numsave=text.length();
          int savechar1=text.charAt(1);
          System.out.println(savechar1); 
          int savechar2=text.charAt(numsave);
          System.out.println(savechar2);The thought behind the length statement would be to have it check how long it is, and then since it would be the length, it would be the index for the last character as well, but apparently that doesn't fly in java because it gives me and error on that line when I compile it.

it checks the first character with
charAt(1), which spits out a number, whereas its
looking for actual characters when using endsWithLook at where you assign the value of savechar1. Is there anything in your code that tells the program you want it to make savechar1 an int? The program will make the type of savechar1 to be exactly what you tell it to be.
Edit: I guess that's not what you were worried about. However, you would have found debugging to be much easier if you could see the actual charcter returned by charAt(1), instead of just the int representation
As for using "endsWith", if you take a look at the charAt(int i) method in String, you'll see that it tells you the index numbers of the first and last characters in the String. What is the index number of the first character? (It's not 1 like you're saying above). What is the index number of the last character compared to String.length()?
Edit: Oh, I guess Gino went ahead and told you straight out what the indexes should be.
Message was edited by:
Asbestos

Similar Messages

  • Matching a string of text with another

    Hello Gurus
    I have what is hopefully a fun problem for someone to help me solve. I was unable to find the relevant commands in the ABAP dictionary and am not the best at ABAP anyway!
    We have field with properties:
    /BIC/OZBARCODE
    Data Type  NUMC
    Length     20
    In reality the data in this field should be 13 characters long and we are not interested in strings that are not this length.
    From the remaining data we want to compare characters 8-12 to another text string, lets call it ABCDE. We are then only interested in those that match.
    eg
    if there were three values for /BIC/OZBARCODE:
    ABCDE
    ABCDEXXXXXXXX
    XXXXXXXABCDEX
    ABCDE - would be deleted as of the wrong length
    ABCDEXXXXXXXX - would be deleted as the relevant string does not fall in the right place
    XXXXXXXABCDEX - would be kept
    No need to give me the whole code, I just need the bits that will say:
    If length of /BIC/OZBARCODE = 13
    and
    if characters 8-12 of /BIC/OZBARCODE = ABCDE
    Many thanks in advance for any help.
    Tom

    Hello Tom,
    you basically will need the strlen( ) operator for getting the length of the string and an offset operation to compare the substring.
      DATA: lv_string(20) TYPE c,
            ln_length     TYPE i.
    lv_string = 'XXXXXXXABCDEX'.
    ln_length = strlen( lv_string ).
    IF ln_length NE 13 or
       lv_string+7(5) NE 'ABCDE'.
      " throw the value away
    ELSE.
      " keep the value
    ENDIF:
    The trouble you will face in your setting is that the field is no string but a numeric character. These fields should be right aligned and cannot contain spaces or letters so the length should always be 20. Furthermore they are right alligned and filled with zeros so if zeros are allowed characters from the business view you might not be able to get the length of the string for sure.
    Kind Regards
    Roman

  • Logic error in a class I wrote...help

    I wrote this class to filter a simplified version of Military time; basically it
    returns a true or false statement to whether a specified string contains
    the appropriate character sequence. My problem is that it seems to
    report false even if my time format is correct.
    example:
    correct time: "0700"
    incorrect time: "700" or invlalid characters "asdf "
    maybe you all could catch me logic error...my head is bust
    class SimpleMilitaryTime
         //Verify that their are only 4 characters in the string
         public boolean verifyLength(String time)
              int textFieldLength;
              boolean flag = true;
              textFieldLength = time.length();
              if (textFieldLength == 4)
                   flag = true;
              else
                   flag = false;
              return flag;
         }//end verify length
         //Method for comparing characters that can be used
         public boolean verifyNumerals( String time )
              boolean flag = true;
              int flagCounter = 0;
              char theChar;
    //testing characters to see if they match or dont
    //match the below lists of char numerals
    //If they don't, the flagcounter is increased by 
    //one and the flag is returned as false
    //because the flagcounter is greater than 0 
    //indicating that they are not all numerals but
    //some other sort of character
              for (int i = 0; i <= time.length(); i++)
                     theChar = (char)time.indexOf(i);
                   switch (theChar)
                        case '0':
                             break;
                        case '1':
                             break;
                        case '2':
                             break;
                        case '3':
                             break;
                        case '4':
                             break;
                        case '5':
                             break;
                        case '6':
                             break;
                        case '7':
                             break;
                        case '8':
                             break;
                        case '9':
                             break;
                        default:
                              flagCounter = flagCounter + 1;
                   }//end of switch
              }//end of for loop
              if (flagCounter < 0 )
                   flag = true;
              else
                   flag = false;
              return flag;
         }//End of Method
         //Method to determine numeral format
         public boolean verifyFormat( String time )
              boolean flag = true;
              boolean hrFlag = true;
              boolean minFlag = true;
              String hr, min;
              hr = time.substring(0, 1);
              min = time.substring(2, 3);
              hrFlag = verifyHrRange( hr );
              //return true if its in the hour range of 0 to 23
              minFlag = verifyMinRange( min );     
                                              //return true if its in the minutes range of 0 to 59
              //If hrFlag or minFlag is false then format does
                                               //not meet the Military Time Format
              if (hrFlag == false || minFlag == false)
                   flag = false;
              else
                   flag = true;
         return flag;
         }//end of Method
         //Verify the Range of Hr  between 0 and 23
         public boolean verifyHrRange( String hr )
              int hrTime;
              boolean flag = true;
              hrTime = Integer.parseInt( hr );
              if ( hrTime >= 0 && hrTime <= 23 )
                   flag = true;
              else
                   flag = false;
         return flag;
         }//End of Method
         //Verify the Range of Minutes  between 0 and 59
         public boolean verifyMinRange( String min )
              int minTime;
              boolean flag = true;
              minTime = Integer.parseInt( min );
              if ( minTime >= 0 && minTime <= 59 )
                   flag = true;
              else
                   flag = false;
         return flag;
         }//End of Method
         //Method validates total time content
         public boolean validateTime( String time )
              boolean flag = true;
              boolean flagLength = true;
              boolean flagNumerals = true;          
              boolean flagFormat = true;          
              flagLength = verifyLength( time );                         //Is the length  == to 4 characters long
              if( flagLength == true )
                   flagNumerals = verifyNumerals( time );               //Is the content made up of numerals
                   if( flagNumerals == true )
                        flagFormat = verifyFormat( time );               //Is the format within MilitaryTime Specs
                        if( flagFormat == true )
                             flag = true;
                        else
                             flag = false;                                             //IF one or all are FALSE then FLAG is set to false
                   else
                        flag = false;
              else
                   flag = false;
              //return status of test run
              return flag;               
         }//End of Method
    }//End of Class

    Interestingly enough, although both examples simplify the logic, I still
    recieve a "false" when testing it. Here is some more code that I use
    when a text field has lost focus. Right now the code is set to just test
    the input.
    The field is inialized to "1234". Once the field gains focus, it immediately sets to "false"...not sure why.?.? Even after resetting field
    to another 4 digit numeral sequence I still get a "false" return instead of
    verifying it as "true. " any ideas?
    here is the code for testing the MilitaryTime class:
    private class TextFieldListener extends FocusAdapter
         //method that listens losing focus of textfield
         public void focusLost( FocusEvent ev )
              boolean flag;
              String indFALSE, indTRUE;
              indFALSE = "FALSE";
              indTRUE = "TRUE";
              int strLength;
              flag = mt.isValidTime(sunMornStartTime_str); //mt is for MilitaryTime
              if (flag == false)
              sunMornStartTime.setText(new String(indFALSE));
              if (flag == true)
              sunMornStartTime.setText(new String(indTRUE));
         }//End of Method
    }//End of private class TextFieldAction

  • My OUTPUT (... looks greek to me, need it in English)

    my output looks like this:
    a >???�??????�??�??�?????�?????????????
    it should have looked like this:
    0001 06/12/1982 01 02 03 04 05 06 07
    Here is my code, its a work in progress, presently im just trying to get one line to print out... then i will add other functions to it.
    Your Database:
    recID mm/dd/ccyy n1 n2 n3 n4 n5 n6 n7
    0001  06/12/1982 01 02 03 04 05 06 07
    0002  06/12/1982 02 03 04 05 06 07 43
    0003  06/12/1982 03 10 12 21 14 41 43
    0004  06/12/1982 04 11 16 22 14 41 43
    0005  06/12/1982 05 12 17 23 14 41 43
    The program: Compares each line(record) and finds records that contain 6 of the same numbers
    So in the above database, it should find that rec1 & rec2 contain 6 same numbers
    Basic Algorithm:
    read in rec1, all 5 records compared against rec1
    read in rec2, remaining 4 records compared against rec2
    read in rec3, remaining 3 records compared against rec3
    for each Record{
       compare to next record
       if 6 numbers the same
          write it out
       else
          get next record to compare
    }//endof ForEachRecord
    import java.io.*;
    public class Find6same
         public static void main( String args[]) throws IOException
              int n = 0;
              int RECORD_SIZE = 36;
          long start = 0L;
          char c;
          //create 2 stringbuffers for holding & comparing records
          StringBuffer a = new StringBuffer(36); //holds current record
          StringBuffer b = new StringBuffer(36); //holds record to compare
          //create the pw stream for output
          File outputFile = new File("C:\\jLotto\\dataFile\\find6.txt");
              PrintWriter pw = new PrintWriter( new FileWriter( outputFile ));
          //create the random access stream for reading & processing
              RandomAccessFile in = new RandomAccessFile("C:\\jLotto\\dataFile\\numberOfBytesIn.txt","r");
          // get the position at which the next read occurs, use getFilePointer as it
          // Returns the position from the beginning of the file, in bytes, at which
          // the next read or write occurs.
          start = in.getFilePointer();
          // Sets the file-pointer, measured from the beginning of this file,
          // at which the next read or write occurs
          in.seek(RECORD_SIZE);
          //a = readData(in); //read in the data for that one record
          for(int i = 0; i<36;i++){
             c = in.readChar();
             a.append(c);
          pw.println( "start >" + start ); //write out the contents of variable n
          pw.println("a >" + a);
          //close both input & output streams
              in.close();
              pw.close();
         }//end of static main
    }//end of class Find6same

    This is what i would like to do:
    (i would prefer to stay away from a file size of 17 bytes bcz im
    mentally challenged), i would like to work with something i recognize...
    data file in:
    0001 06/12/1982 01 02 03 04 05 06 07
    0002 06/12/1982 02 03 04 05 06 07 43
    0003 06/12/1982 03 10 12 21 14 41 43
    0004 06/12/1982 04 11 16 22 14 41 43
    0005 06/12/1982 05 12 17 23 14 41 43
    0006 06/12/1982 06 13 18 24 14 41 43
    0007 06/12/1982 09 10 11 12 13 14 43
    0008 06/12/1982 08 09 10 11 12 13 14
    0009 06/12/1982 09 10 11 12 13 14 15
    import java.io.*;
    public class Find6same4
       public static void main( String args[]) throws IOException
         long start = 0L;   // this holds the last postion held b4 read was called
         int moveAhead = 0; // this moves the read operation ahead by 36 bytes
         int foundOne = 0; //counts how many numbers the 2 arrays have in common
         int recordsProcessed = 1;//counts how many records have been processed, total of 10 recs in file
          //create the pw stream for output
          File outputFile = new File("C:\\jLotto\\dataFile\\find6.txt");
          PrintWriter pw = new PrintWriter( new FileWriter( outputFile ));
          //create the random access stream for reading & processing
         RandomAccessFile raf = new RandomAccessFile("C:\\jLotto\\dataFile\\numberOfBytesIn.txt","r");
          // get the record that you will compare all other
          // records against & put in "hold" array
    while (recordsProcessed <11){
          String[] hold = new String[36]; //store as characters
          hold = raf.readFully;  //read first 36 chars into hold array
          // locates where your next "hold" is that you have to read
          // in & compare all other records against
          start = raf.getFilePointer();
          //loop thru remaining records until EOF, to see if 6 numbers are the same in both arrays
          while (raf.seek != EOF){
              recordsProcessed++;
              raf.seek(moveAhead);// Sets the file-pointer at which the next read or write occurs
              String[] nxtRecord = new String[36]; //store as characters
              compareArray = raf.readFully;  //read first 36 chars into comparing array
              // now compare hold[] & nxtRecord[]
              // compare characters held at the following index positions> 17, 20, 23, 26, 29, 32, 35
              for (int i=17; i<38; i=3+i){
                  for (int x = 17; x<38; x=x+3){
                      if (Integer.parseInt( hold[i] )= Integer.parseInt(nxtRecord[x]) )
                      foundOne++;
                  }//endof for x
                  if (foundOne > 5)// if the 2 arrays have 6 numbers in common
                      printToFile(nxtRecord);
                  foundOne = 0;
               }//endof for I
           moveAhead= start+36;//the next "hold" record to be read in is at this position
    }//end of recordsProcessed
    public void printToFile( thisLine ){
      pw.println( thisLine );
      pw.append( "/n" );
    //end of find6samehere are my errors
    C:\jLotto\modules\FindNums\Find6same4.java:53: illegal start of expression
    public void printToFile( thisLine ){
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:56: ';' expected
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:24: cannot resolve symbol
    symbol : variable readFully
    location: class java.io.RandomAccessFile
    hold = raf.readFully; //read first 36 chars into hold array
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:31: cannot resolve symbol
    symbol : variable seek
    location: class java.io.RandomAccessFile
    while (raf.seek != EOF){
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:31: cannot resolve symbolsymbol : variable EOF
    location: class Find6same4
    while (raf.seek != EOF){
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:35: cannot resolve symbol
    symbol : variable compareArray
    location: class Find6same4
    compareArray = raf.readFully; //read first 36 chars into comparing array
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:35: cannot resolve symbol
    symbol : variable readFully
    location: class java.io.RandomAccessFile
    compareArray = raf.readFully; //read first 36 chars into comparing array
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:41: unexpected type
    required: variable
    found : value
    if (Integer.parseInt( hold[i] )= Integer.parseInt(nxtRecord[x]) )
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:45: cannot resolve symbol
    symbol : method printToFile (java.lang.String[])
    location: class Find6same4
    printToFile(nxtRecord);
    ^
    C:\jLotto\modules\FindNums\Find6same4.java:49: possible loss of precision
    found : long
    required: int
    moveAhead= start+36;//the next "hold" record to be read in is at this position
    ^
    10 errors

  • Feedback-desperate!

    Okay, my program generates a 3 letter string. The user guess'. Now depending on how close they are they should receive feedback.
    A &ldquo;W&rdquo; indicates that they don&rsquo;t have any characters right. One or more &ldquo;O&rdquo;s indicates that they have a correct character/s, but in the incorrect position/s.
    Finally, one or more &ldquo;C&rdquo;s indicates that they have the correct character/s in the correct position/s.
    I have started but need some help;
    String cString = ""; //for storing Cs
    String oString = ""; //for storing Os
    loop over the first string guess.
    for(int i=0; i<3; i++)
    //get the i th char from the String to compare to the other String.
    char guessCharI = guess.charAt(i);
    //loop over random String to compare
    for(int j=0; j<3; j++)
    //now do a similar thing in getting the j th char from the random String
    char randCharJ = random.charAt(j);
    //if i==j and the chars are the same, you can add a C to the
    cString
    //if i!=j and the chars are the same, you can add a O to the
    oString.Help..... Can someone please help me start?
    I hope I haven't lost anyone.
    {font:'PrimaSans BT,Verdana,sans-serif'}<span class="hmmessage">
    {font}

    A &#8220;W&#8221; indicates that they don&#8217;t have any characters right. One or more &#8220;O&#8221;s indicates that they have a correct character/s, but in the incorrect position/s.Finally, one or more &#8220;C&#8221;s indicates that they have the correct character/s in the correct position/s.
    That's kind of looking at it backwards. Provided that care is taken to ensure that the two Stirngs are in fact the same length --
    -- Loop though once comparing characters at the same position
    -- Whan a match is found, increment a counter and replace the character in both Strings at that position with some character that is illegal to your words .. like @ or _.
    -- Loop through in nested loops comparing legal characters in cString with all legal characters in oString.
    -- Same as second step above
    -- Loop through either String and count the remaining legal characters.
    Using [String#toCharArray|http://java.sun.com/javase/6/docs/api/java/lang/String.html#toCharArray()] may be useful for this exercise.
    I leave it as an exercise to you to combine the loops into more efficient code, but do that only after you have it working with 3 separate passes.
    db

  • Why doesnt this work, its so simple

    The following piece of code I guess should print "THEY ARE EQUAL" but it doesnt. I dont know why???????????? anybody help.
    String check = new String("new���".getBytes("iso-8859-1"), "iso-8859-1");
    for(int i =0 ; i< check.length(); i++)
    if(check.charAt(i)=='���') System.out.println("THEY ARE EQUAL");
    }

    You aren't comparing whether the two strings contain
    the same data, you are comparing whether the two
    references point to the same objects. Try it again
    using the .equals() method to compare the contents of
    the two strings instead of using ==.For the first time in my life have I seen DrClap err. So he is human too. amit234 is comparing characters and not Strings
    I found the solution to your problem your the corresponding line in your code with this one and it would work
    if(check.charAt(i)=='\u20AC') System.out.println("THEY ARE EQUAL");
    happy coding

  • What' wrong with      ${pageScope.charVar=='x'}

    Hi,
    I've got a weird problem with EL. Here is the JSP:
    <%
    pageContext.setAttribute("charVar", new Character('x'));
    %>
    ${pageScope.charVar=='x'}
    -------------------------------------------------An exception is thrown as following:
    javax.servlet.ServletException: An exception occured trying to convert String "x" to type "java.lang.Long"
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.jsp1_jsp._jspService(org.apache.jsp.jsp1_jsp:68)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    How can I compare a char var to a char literal in EL?
    Any help is appreciated.
    Regards,
    Anderson

    According to the JSP spec (JSP2.3.5.6), the following rules apply:
    When comparing using ==:
    If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to
    Long and apply operator
    And then JSP2.8.3:
    Converting character to number:
    If A is Character, convert A to new Short((short)a.charValue())
    Basically it means that you can't compare characters directly like this in EL.
    You will have to compare using the character codes instead
    ${pageScope.charVar == 120}  // 120 == 'x'No its not nice.
    I guess EL doesn't really support characters that well.
    Cheers,
    evnafets

  • Special characters are not shown in compare document report in Acrobat X

    Hi All,
    I have a pdf document which is having some special characters like üὄ. Now I have updated the document with few corrections and while compare document in Acrobat X special characters are not shown in the report.
    Can any one please look into this and give suggestion.

    Hi Steve,
    Thanks for your reply.
    Platform - PC
    Application - 3B2 and Acrobat 9
    So far we have seen this kind of issue in only one document. In the below screenshot you can see 2 pdf files, the right side one is my MS pdf and the left side one is the exported pdf from 3B2 application both the files having the special characters such as . I just did the text comparison however both   and  is missing in the exported pdf but the reports shown the changes for  characters only wherever the  charactes is missing the report not shown the changes properly(See highlighted in yellow).
    Please let me know if you need more deatails.

  • How to compare two strings whether both are equal while ignoring the difference in special characters (example: & vs & and many others)?

    I attempted to compare two strings whether they are equal or not. They should return true if both are equal.
    One string is based on Taxonomy's Term (i.e. Term.Name) whereas other string is based on String object.
    The problem is that both strings which seem equal return false instead of true. Both string values have different special characters though their special characters are & and &
    Snapshot of different design & same symbols:
    Is it due to different culture or language?
    How to compare two strings whether both are equal while ignoring the difference in special characters (& vs &)?

    Hi Jerioon,
    If you have a list of possible ambiguous characters the job is going to be easy and if (& vs &) are the only charracters in concern awesome.
    You can use the below solution.
    Before comparing pass the variables through a replace function to standarize the char set.
    $Var = Replace($Var,"&","&")
    This is going to make sure you don't end up with ambiguous characters failing the comparison and all the char are "&" in this case.
    Similar technique is used to ignore Character Cases 'a' vs. 'A'
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Read Russian Characters and compare them.

    All,
    My task is to read an XML file and convert all of the Russian Characters in the file to latin characters. (e.g. &#1076; would be e and &#1078; would be h)
    When I read the Russian Characters I get wierd characters that look like ??. I tried to read the file in as UTF8 but now instead of the wierd characters I get ???? for the characters.
    The input file looks like this.
    <?xml version="1.0"?>
    <russian>
         <para>
              <text>testing</text>
              <ru>&#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088;</ru>
         </para>
         <para><ru>&#1092; &#1090; &#1074;&#1086;&#1076;&#1092;&#1083;&#1074; &#1072;&#1086;&#1092;&#1099;&#1074;&#1076;&#1072;&#1083;&#1092;&#1086; &#1099;&#1074; &#1092;&#1099;&#1076;&#1074;&#1078;&#1083;&#1086;&#1072; </ru></para>
         <ru/>
    </russian>
    When I read it in I get.
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/css" href="test.css"?>
    <russian>
         <para>
              <text>testing</text>
              <ru>???? ???? ???? ????</ru>
         </para>
         <para><ru>? ? ?????? ?????????? ?? ???????? </ru></para>
         <ru/>
    </russian>
    So I can't compare the russian characteres to convert them.
    Is there anyway to read them in and perserve what they are. I don't care what they look like when the come in just that they are distinguishable so I can compare them and change them to the right latin character.
    Thanks for the help.
    Michael

    Thanks for the reply.
    Ok,
    You asked for it so I will give it to you.
    I took your advice and made sure that the encoding was correct. I resaved the xml file as a UTF-8 encoded page in notepad. (It was already UTF8 but I did it anyway) Dreamweaver confirms that the file is indeed of UTF8 encoding. So assuming that if I type in russian letters in notepad and save the file as a UTF8 file then the characters are UTF8.
    So the input file is this.
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/css" href="test.css"?>
    <russian>
         <para>
              <text>testing</text>
              <ru>&#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088; &#1080;&#1076;&#1092;&#1088;</ru>
         </para>
         <para><ru>&#1040; &#1099;&#1092;&#1083;&#1086; &#1092;&#1074;&#1086;&#1072; &#1092;&#1076;&#1083;&#1099; &#1072;&#1086;&#1078;&#1076;&#1072;&#1074; &#1087;&#1083;&#1086;&#1099;&#1076;&#1072;&#1074;&#1086; &#1087;&#1099;&#1072;&#1087; &#1086;</ru></para>
         <ru/>
    </russian>
    I read in the file using this code.
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("test.xml"), "UTF8"));
                   StringBuffer sb = new StringBuffer();
                   while ((str = in.readLine())!= null){
                        sb.append(str);
                        sb.append(System.getProperty("line.separator"));          
                   theString = sb.toString();
                   System.out.println(theString);
    The System.out.println(theString); outputs this.
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/css" href="test.css"?>
    <russian>
         <para>
              <text>testing</text>
              <ru>???? ???? ???? ????</ru>
         </para>
         <para><ru>? ? ?????? ?????????? ?? ???????? </ru></para>
         <ru/>
    </russian>
    Later on in my program I have an array that compares the russian to the russian character array.
    char[] russianLett = new char[66];
    russianLett[0] = '&#1040;';
    russianLett[1] = '&#1066;';
    russianLett[2] = '&#1042;';
    ETC.... for all capital and lowercase russsian letters.
    So it doesn't find ? in my array and thus returns ?.
    Maybe you can se what is going wrong.
    You can download the code from http://www.michaelsworld.us/misc/project.zip .

  • Compare ASCII Characters

    I scan a barcode and the barcode contains 16 characters.  Using 0 as my first character, I have a single letter (a to z or A to Z, upper or lower case).  In positions 5 and 6 I have two letters (a to z or A to Z).  How do I ensure that the first character is a letter and not a number in TestStand (3.0)?  The second example has two consecutive letters (any combination of, either upper or lower case), how do ensure these two characters are letters and not numbers or special characters? Positions 0, 5 and 6 will always have a letter, never a number and never the same.
    Tony

    If you still want to do it in TestStand, you have Mid(), Asc(), Chr(), <, >, ==, StrComp(), etc.. to manipulate and compare strings and characters.
    For example, it you want to know if a particular character is alphabetic:
    Locals.characterInUpperCase = ToUpper(Mid(Locals.stringOfInterest, Locals.characterIndex, 1)),
    Locals.isAlphabetic = StrComp(Locals.characterInUpperCase , "A") >= 0 && StrComp(Locals.characterInUpperCase , "Z") <= 0
    Admittedly, an IsApha() function would be nice. 

  • Comparing special characters

    How to compare the special characters ?
    I have used compareNocase but still I am unable to compare.
    Example :
    I want to compare these values
    1.Master™ selvan
    2.Master®selvan
    thanks in Advance
    Anbu

    Hi Anbu,
    Make a try with this...
    <cfset string1="Master™ selvan">
    <cfset string2="Master® selvan">
    <cfset tobase_string1=ToBase64(string1)>
    <cfset tobase_string2=ToBase64(string2)>
    <cfoutput>
    Base64 Representation of Strings : <br><br>
    String 1 : Actual Value : #string1# Converted Value :
    #tobase_string1# <br>
    String 2 : Actual Value : #string2# Converted Value :
    #tobase_string2# <br><br>
    </cfoutput>
    Equality : <cfif #tobase_string1# eq
    #tobase_string2#><cfoutput>Equal</cfoutput><cfelse><cfoutput>Not
    Equal</cfoutput></cfif>

  • Compare Docuements Option - not finding the Junk characters

    While comparing the PDFs (older and new document), "technique" vs "tecÚique" word, did not shows errors in Compare Docuement Option:
    • The fonts are properly embedded
    • While printing the pdf tecÚique word print tecÚique.
    • While searching tecÚique word in Acrobat, the alert shows "No matches were found", but searching "technique" word it is showing tecÚique.
    See the attached screen shot, and the PDF created from Adobe InDesign.
    Note: This issue is not resolved in InDesign forums, but I want find the solution from Acrobat forums, Please advice for this issues (http://forums.adobe.com/message/6135769).
    Thanks & Regards,
    Raghu

    Again this issue is happen in another PDF file, but I have not yet solved this issue please advice.

  • Urgent: comparing multi-byte characters to a single byte character!

    Let's say I have two strings, they have the same contents but use different encoding, how do I compare them?
    String a = "GOLD";
    String b = "G O L D ";
    The method a.equals(b) doesn't seem to work.

    try this:
    String a = "GOLD";
    String b = "G O L D ";
    boolean bEqual = true;
    int iLength = a.length();
    int j = 0;
    for (int i = 0; i < iLength; i++)  {
       while(b.substring(j,1).equals(" "))
          j++;
       if(!a.substring(i, 1).equals(b.substring(j,1))  {
          bEqual = false;
          break;
    }

  • How to compare the first and last characters of strings?

    lets say we have a name column with values;
    c1
    Antu Anamentu
    Steven Smith
    Since A=A and U=U for the first value we need a TRUE and FALSE for the second value SQL. Is this possible to do with REGEXP functions on 10gR2.
    Thank you.

    Hi Frank,
    Just minor correction: REGEXP_LIKE (Name1, '^(.).*(.) \1.*\2$') ;
    Explanation: ^(.) =>^ specifies the next char is first char
                                . dot specifies single character
                               ()  defines group which can be backrferenced
                       .* => Any number of characters as we want only first and last character
                      (.)  => (.)space The space signifies that we want to remember last char of first word or char before space
                       \1 => It recalls first group which we saved for backreference using (.)
                       .* => Any number of chars
                      \2 =>  It recalls first group which we saved for backreference using (.)
                       $ => It specifies the char before this is last charHope it clarifies :)
    SQL> WITH t AS
    SELECT 'Antu Anamentu' Name1 FROM DUAL UNION ALL
    SELECT 'Steven Smith' Name1 FROM DUAL
    SELECT Name1
    FROM t
    WHERE REGEXP_LIKE (Name1, '^(.).*(.) \1.*\2$')  ;
    NAME1
    Antu Anamentu

Maybe you are looking for

  • F1 help in webdynpro for java

    Hello Exports, I wish to implement F1 help for fields on webdynpro page. Is this possible in webdynpro for Java? Any kind of reference in this regard will be useful. Best regards, Nakul

  • Asset Value decrease

    HI All, here my requirement is one asset having net book value 100 rs. and it was depreciated to 99 rs.(now net book value 1rs that is memo value) in the year of 2008. Now user wants to post credit note for 50 rs. i.e net book value is -49rs. my view

  • What is user defined planning dimension?

    What is user defined planning dimension? 6. What is user-defined custom planning dimension?

  • When do you go for transitive attributes

    hi all, What is the significance of transitive attributes. if i am going to extract the data from flat file for that transitive attribute then how should i do that. thanxs haritha

  • Re. bridge CC v 6.016

    Sorry, can't find any other way or place to ask this.  I have MacPro early 2008 ID 3.1, Mac OS 10.6.8.  Problem seems recent after Bridge upgrade.  Thumbnails display in bridge vary tremenduously in "exposure," one is all washed out, adjacent too dar