How to parse characters non ascii in a string

i am stucked in this crictical problem and i don't know how to cater this. I sometimes receive this String ����►☻☺ and sometimes these are non US-ASCII characters. These ����►☻☺ characters are replaced by ????? and is represented as it is. I sometime receive this character �� too. These characters are in ANSI list but i want to receive only US-ASCII. Please help me out that how to identify these characters in the string.

Basically i am getting that string from the user in an sms. The text of the sms is saved in the database.I get that sms from database in string form. now i want to parse the string to identify the non us-ascii characters in the string. This parsing is important because when i try to post data on the url i get the http response code 400 which creates an exception and i get stucked in an infinite while loop.
HttpURLConnection urlcon =null;
String postingdata="&message="+ URLEncoder.encode(ob.getmessage(),"UTF-8")
System.out.println(postingdata);
URL url = new URL("http://someurl");
urlcon = (HttpURLConnection)url.openConnection();
urlcon.setDoOutput(true);
urlcon.setRequestMethod("POST");
OutputStreamWriter wr = new OutputStreamWrite(urlcon.getOutputStream());
wr.write(postingdata);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
rd.close();
wr.close();

Similar Messages

  • How to Parse Characters?

    Hi Folks,
    Can anyone help me out on how to parse the characters in data services. Here is the example:
    Rule: Parse first three characters          MU_1000008 to     1000008
    What is the function I can use?
    Any help is appreciated.
    Thank you

    Hi,Dear All,
    I am Trying to go from
    Id
    LS001
    LS003
    NT006
    LS007
    ES009
    LS004
    TO  OUTPUT
    Col          ID
    T1          LS001,ES009,LS003
    T2          NT006
    T3          LS007,LS004
    pls help me out or give me  hint or idea so i can use that.
    Regards
    Varsha

  • How to parse select lines in an html string?

    I've been writing a program to deal with demographic data and the first server it calls returns an xml string. However, the backup server returns an html string instead of an xml string, so the formatting is a bit different. I was going to use a regex as I did with the xml server, but regex's don't work that well with html. i was wondering if you could offer some advice on how to effectively parse the html string? It is in this format <html>
    <head>
    <meta name="Description" content="ZIP Code Demographics"/>
    <meta name="Keywords" content="zip, zip code, zipcode, demographics, 2000, county, lookup, city, state"/>
    <title>ZIP Code Demographics Lookup</title>
    <link rel="stylesheet" type="text/css" href="http://www.MelissaData.com/style.css" />
    </head>
    <body topmargin="0" onload="document.getElementById('text1').focus()">
    <div align="center">
    <!--Start of top.asp 9/2/08 Ray-->
    <script type='text/javaScript' src='http://www.melissadata.com/cgi-bin/lib.js'></script>
        <table align="center" border="0" cellpadding="0" cellspacing="0" width="744" style="font-size:8pt; font-family:Arial; color: #666666">
            <tr valign='middle'  height='24'>
                 <td align="left" rowspan=2><a href="/index.htm">
                    <img border="0" src="http://www.melissadata.com/home/new1207/MelissaData-logo.gif" alt="Melissa Data Home Page" /></a><img border="0" src="http://www.melissadata.com/home/new1207/1-800-number.gif" width="112" height="22" alt="Call 1-800-MELISSA for Data Quality Solutions" /></td>
                <td colspan='2' align="right">
                    <font size="1" face="Verdana">
                <script type="text/javaScript">var r=uCookie("r"); var s=uCookie("s"); var n=uCookie("n");
                    //document.write (document.cookie);
                    if (r == "YES" && s == "IN" && n != "" ) document.write ("Hello <b>" + n.replace(/\+/g," ") + "<\/b>   [<font size=1><a href=/user/signout.aspx>Sign out<\/a>, <a href=/user/user_account.aspx>My Account<\/a></font>]");else document.write (" <a href=/user/signin.aspx>Sign In<\/a> ");
                </script></font></td></tr>
            <tr height='24'>
                <form method="get" action="http://w2.melissadata.com/cgi-bin/search.asp">          
                <td align="right" height=30>               
                    <a href="/netcart/order1.aspx"><img border="0" src="http://www.melissadata.com/home/new1207/Hompage-shoppincart.gif" alt="Shopping Cart" /></a>
                    <a style="color: #666666" href="/netcart/order1.aspx">Buy</a>
                    | <a style="color: #666666" href="/cgi-bin/newsletters.asp">Newsletters</a> | Search
                    <input name="indata" style="font-size:7pt; font-family:Arial" size="10" /><input type="image" src="http://www.melissadata.com/home/new1207/hompage-arrow.gif" style="vertical-align: middle"  value="Search" name="submit1" />
        </td></form></tr>
        </table>
        <style="font-size:10pt; font-family:Arial; color: #0066cc" type="text/css">
        <table align="center" border="0" cellpadding="4" cellspacing="0" width="744">
            <tr>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/products/index.htm">Products</a></b></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/solutions/index.htm">Solutions</a></b></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/download.htm">Downloads</a> </b></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/tech/tech.html">Support</a> </font></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/resources/index.htm">Resources</a></b></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/lookups/index.htm">Lookups</a></b></td>
                <td align="center" width="106">
                    <b><a style="text-decoration: none" href="/cgi-bin/contact.asp">Contact Us</a></b></td></tr>   
        </table></style>
    <!-- Start Image BanAd.asp-->
    <div align=center><a href='/cgi-bin/BanAd.asp?id=135'><img alt='Click here' src='/cgi-bin/BanImage.asp?id=135'></a></div><!-- End Image BanAd.asp-->
    <!--TitleBorder in Shared.asp -->
    <table width="744" cellspacing=0 border=1 bgcolor="#F7F7F7"><tr><td align=left><font color="#ce0000" size="5">ZIP Code Demographics Lookup</font></td><form><td width=120 align=center><input title='Help for ZIP Code Demographics Lookup' type=button onClick=openHelpWindow('/lookups/help/zipdemo2000.asp') value=Help>  <a title='Lookups home page' href=/lookups/index.htm>Index</a></td></form></tr></table>
    <!--TitleBorder End-->
    <form action="ZipDemo2000.asp" name="Demo2000">
    <table width="400" class="Disp">
    <tr><td align="center"><b>Enter a 5-Digit ZIP Code</b>
        <input class="Disp" title="Enter a ZIP Code" id="text1" size="5" name="ZipCode" maxlength="5"/> <input type="submit" value="Submit"/>
    </td></tr>
    </table>
    </form>
    <table cellspacing="0" cellpadding="1" width="750" border="2" bgcolor="#ffffcc">
    <tr bgcolor="lightblue"><td colspan="4" align="center">Year 2000 Demographics of <br><b>ZIP Code 90041</b><br><b>LOS ANGELES, California</b><br><a href=mapzipv.asp?zip=90041>Map of ZIP Code</a></td></tr>
    <tr bgcolor="#bbffff"><td>TOTAL POPULATION [1]</td><td >P001</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P001</td></tr>
    <tr><td>   Total</td><td align=right ><b> 27,864</b></td></tr>
    <tr bgcolor="#bbffff"><td>URBAN AND RURAL [6]</td><td >P002</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P002</td></tr>
    <tr><td>   Total:</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>         Urban:</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>           Inside urbanized areas</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>           Inside urban clusters</td><td align=right ><b> 0</b></td></tr>
    <tr><td>         Rural</td><td align=right ><b> 0</b></td></tr>
    <tr><td>         Not defined for this file</td><td align=right ><b> 0</b></td></tr>
    <tr bgcolor="#bbffff"><td>RACE [8]</td><td >P007</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P007</td></tr>
    <tr><td>   Total:</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>         White alone</td><td align=right ><b> 13,429</b></td></tr>
    <tr><td>         Black or African American alone</td><td align=right ><b> 630</b></td></tr>
    <tr><td>         American Indian and Alaska Native alone</td><td align=right ><b> 242</b></td></tr>
    <tr><td>         Asian alone</td><td align=right ><b> 7,123</b></td></tr>
    <tr><td>         Native Hawaiian and Other Pacific Islander alone</td><td align=right ><b> 42</b></td></tr>
    <tr><td>         Some other race alone</td><td align=right ><b> 4,738</b></td></tr>
    <tr><td>         Two or more races</td><td align=right ><b> 1,660</b></td></tr>
    <tr bgcolor="#bbffff"><td>HISPANIC OR LATINO BY RACE [17]</td><td >P008</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P008</td></tr>
    <tr><td>   Total:</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>         Not Hispanic or Latino:</td><td align=right ><b> 17,109</b></td></tr>
    <tr><td>           White alone</td><td align=right ><b> 8,468</b></td></tr>
    <tr><td>           Black or African American alone</td><td align=right ><b> 555</b></td></tr>
    <tr><td>           American Indian and Alaska Native alone</td><td align=right ><b> 105</b></td></tr>
    <tr><td>           Asian alone</td><td align=right ><b> 7,053</b></td></tr>
    <tr><td>           Native Hawaiian and Other Pacific Islander alone</td><td align=right ><b> 30</b></td></tr>
    <tr><td>           Some other race alone</td><td align=right ><b> 73</b></td></tr>
    <tr><td>           Two or more races</td><td align=right ><b> 825</b></td></tr>
    <tr><td>         Hispanic or Latino:</td><td align=right ><b> 10,755</b></td></tr>
    <tr><td>           White alone</td><td align=right ><b> 4,961</b></td></tr>
    <tr><td>           Black or African American alone</td><td align=right ><b> 75</b></td></tr>
    <tr><td>           American Indian and Alaska Native alone</td><td align=right ><b> 137</b></td></tr>
    <tr><td>           Asian alone</td><td align=right ><b> 70</b></td></tr>
    <tr><td>           Native Hawaiian and Other Pacific Islander alone</td><td align=right ><b> 12</b></td></tr>
    <tr><td>           Some other race alone</td><td align=right ><b> 4,665</b></td></tr>
    <tr><td>           Two or more races</td><td align=right ><b> 835</b></td></tr>
    <tr bgcolor="#bbffff"><td>SEX BY AGE [49]</td><td >P012</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P012</td></tr>
    <tr><td>   Total:</td><td align=right ><b> 27,864</b></td></tr>
    <tr><td>         Male:</td><td align=right ><b> 13,324</b></td></tr>
    <tr><td>           Under 5 years</td><td align=right ><b> 862</b></td></tr>
    <tr><td>           5 to 9 years</td><td align=right ><b> 974</b></td></tr>
    <tr><td>           10 to 14 years</td><td align=right ><b> 872</b></td></tr>
    <tr><td>           15 to 17 years</td><td align=right ><b> 525</b></td></tr>
    <tr><td>           18 and 19 years</td><td align=right ><b> 511</b></td></tr>
    <tr><td>           20 years</td><td align=right ><b> 257</b></td></tr>
    <tr><td>           21 years</td><td align=right ><b> 287</b></td></tr>
    <tr><td>           22 to 24 years</td><td align=right ><b> 569</b></td></tr>
    <tr><td>           25 to 29 years</td><td align=right ><b> 969</b></td></tr>
    <tr><td>           30 to 34 years</td><td align=right ><b> 1,024</b></td></tr>
    <tr><td>           35 to 39 years</td><td align=right ><b> 1,140</b></td></tr>
    <tr><td>           40 to 44 years</td><td align=right ><b> 1,077</b></td></tr>
    <tr><td>           45 to 49 years</td><td align=right ><b> 987</b></td></tr>
    <tr><td>           50 to 54 years</td><td align=right ><b> 822</b></td></tr>
    <tr><td>           55 to 59 years</td><td align=right ><b> 647</b></td></tr>
    <tr><td>           60 and 61 years</td><td align=right ><b> 215</b></td></tr>
    <tr><td>           62 to 64 years</td><td align=right ><b> 270</b></td></tr>
    <tr><td>           65 and 66 years</td><td align=right ><b> 155</b></td></tr>
    <tr><td>           67 to 69 years</td><td align=right ><b> 258</b></td></tr>
    <tr><td>           70 to 74 years</td><td align=right ><b> 320</b></td></tr>
    <tr><td>           75 to 79 years</td><td align=right ><b> 252</b></td></tr>
    <tr><td>           80 to 84 years</td><td align=right ><b> 183</b></td></tr>
    <tr><td>           85 years and over</td><td align=right ><b> 148</b></td></tr>
    <tr><td>         Female:</td><td align=right ><b> 14,540</b></td></tr>
    <tr><td>           Under 5 years</td><td align=right ><b> 864</b></td></tr>
    <tr><td>           5 to 9 years</td><td align=right ><b> 949</b></td></tr>
    <tr><td>           10 to 14 years</td><td align=right ><b> 875</b></td></tr>
    <tr><td>           15 to 17 years</td><td align=right ><b> 534</b></td></tr>
    <tr><td>           18 and 19 years</td><td align=right ><b> 592</b></td></tr>
    <tr><td>           20 years</td><td align=right ><b> 285</b></td></tr>
    <tr><td>           21 years</td><td align=right ><b> 264</b></td></tr>
    <tr><td>           22 to 24 years</td><td align=right ><b> 600</b></td></tr>
    <tr><td>           25 to 29 years</td><td align=right ><b> 932</b></td></tr>
    <tr><td>           30 to 34 years</td><td align=right ><b> 1,035</b></td></tr>
    <tr><td>           35 to 39 years</td><td align=right ><b> 1,026</b></td></tr>
    <tr><td>           40 to 44 years</td><td align=right ><b> 1,131</b></td></tr>
    <tr><td>           45 to 49 years</td><td align=right ><b> 1,038</b></td></tr>
    <tr><td>           50 to 54 years</td><td align=right ><b> 970</b></td></tr>
    <tr><td>           55 to 59 years</td><td align=right ><b> 689</b></td></tr>
    <tr><td>           60 and 61 years</td><td align=right ><b> 261</b></td></tr>
    <tr><td>           62 to 64 years</td><td align=right ><b> 327</b></td></tr>
    <tr><td>           65 and 66 years</td><td align=right ><b> 208</b></td></tr>
    <tr><td>           67 to 69 years</td><td align=right ><b> 307</b></td></tr>
    <tr><td>           70 to 74 years</td><td align=right ><b> 482</b></td></tr>
    <tr><td>           75 to 79 years</td><td align=right ><b> 450</b></td></tr>
    <tr><td>           80 to 84 years</td><td align=right ><b> 331</b></td></tr>
    <tr><td>           85 years and over</td><td align=right ><b> 390</b></td></tr>
    <tr bgcolor="#bbffff"><td>MEDIAN AGE BY SEX [3]</td><td >P013</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Total population</td><td >P013</td></tr>
    <tr bgcolor="#bbffff"><td>Median age--</td><td >P013</td></tr>
    <tr><td>         Both sexes</td><td align=right ><b> 35.3</b></td></tr>
    <tr><td>         Male</td><td align=right ><b> 34.0</b></td></tr>
    <tr><td>         Female</td><td align=right ><b> 36.6</b></td></tr>
    <tr bgcolor="#bbffff"><td>HOUSEHOLDS [1]</td><td >P015</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Households</td><td >P015</td></tr>
    <tr><td>   Total</td><td align=right ><b> 9,375</b></td></tr>
    <tr bgcolor="#bbffff"><td>POPULATION IN HOUSEHOLDS [1]</td><td >P016</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Population in households</td><td >P016</td></tr>
    <tr><td>   Total</td><td align=right ><b> 26,409</b></td></tr>
    <tr bgcolor="#bbffff"><td>AVERAGE HOUSEHOLD SIZE [1]</td><td >P017</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Households</td><td >P017</td></tr>
    <tr><td>   Average household size</td><td align=right ><b> 2.82</b></td></tr>
    <tr bgcolor="#bbffff"><td>FAMILIES [1]</td><td >P031</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Families</td><td >P031</td></tr>
    <tr><td>   Total</td><td align=right ><b> 6,326</b></td></tr>
    <tr bgcolor="#bbffff"><td>POPULATION IN FAMILIES [1]</td><td >P032</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Population in families</td><td >P032</td></tr>
    <tr><td>   Total</td><td align=right ><b> 21,653</b></td></tr>
    <tr bgcolor="#bbffff"><td>AVERAGE FAMILY SIZE [1]</td><td >P033</td></tr>
    <tr bgcolor="#bbffff"><td>Universe: Families</td><td >P033</td></tr>
    <tr><td>   Average family size</td><td align=right ><b> 3.42</b></td></tr>
    </table>
    <!-- Start of bottom.asp-->
        <hr width="730" />
        <span style='font-size:8pt'>
        <a href="http://www.melissadata.com/enews/advisorarticles/index.htm">Articles</a> | 
        <a href="javascript:window.external.AddFavorite('http://www.melissadata.com/lookups/zipdemo2000.asp', 'ZIP Code Demographics Lookup')" target="_self">Bookmark</a> | 
        <a href="http://www.melissadata.com/cgi-bin/improve.asp?web">How Can We Improve?</a> | 
        <a href="http://www.melissadata.com/cgi-bin/batchprocessing.asp">Batch Processing</a> | 
        <a href="http://www.melissadata.com/cgi-bin/send.asp?Send2Friend">Email to Friend</a> | 
        <a href="http://www.melissadata.com/cgi-bin/catalogres.asp">Free Catalog</a> | 
        <a href="http://forum.melissadata.com/default.aspx">Forums</a> | 
        <a href="http://www.melissadata.com/terms-of-use.htm">Terms of Use</a>
        <font color="#ddddff"><br />  
        <script type="text/javascript"> var r=uCookie("r"); var f=uCookie("f"); var c=uCookie("c"); var l=uCookie("l");
            //document.write (r + ":" + f + ":" + c + ":" + l);</script></font></span>
    <!-- End of bottom.asp-->
    </div>
    </body>
    </html>.
    The numbers I wanted to extract are the age groups of "Under 5 years," "5 to 9 years," "10 to 14 years," and "15 to 17 years," from both male and female groups, which should add up to 8 numbers total. Here is the backup server portion of my program as well, so you can see what i'm doing.
    import java.net.*;
    import java.net.URL;
    import java.net.URLConnection;
    import java.net.HttpURLConnection;
    import java.io.*;
    import java.io.DataOutputStream;
    import java.io.BufferedReader;
    import java.io.StringReader;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.util.Scanner;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.util.Arrays;
    public class TriParser
         static Scanner sc = new Scanner(System.in);
         public static int[] findValues(String text, String gender, String[] labels)
                Matcher m = Pattern.compile("<td>(.*?)</td>",
               Pattern.MULTILINE | Pattern.DOTALL).matcher(text);
                String allValues = m.find() ? m.group(1) : null; // TODO: handle if 'null' is returned!
                int[] values = new int[labels.length];
                for(int i = 0; i < labels.length; i++)
                  m = Pattern.compile(labels[i]+"[^>]+>(\\d+)").matcher(allValues);
                  if(m.find()) values[i] = Integer.parseInt(m.group(1));
                return values;
         public static void main(String[] args) throws Exception
            int zip;
            boolean validInteger;//indicates if zipcode is valid (has to be 5 digits)
            do
                    System.out.print("Enter a five-digit zipcode: ");
                    zip = sc.nextInt();
                    validInteger = true;
                    if((zip < 10000) || (zip > 99999))
                            validInteger = false;
                            System.out.println("Invalid Entry.  Please re-enter zipcode.");
            while(!validInteger);
            System.out.println(zip);     
            //String requestPart1 ="query=PREFIX+dc%3A++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E+%0D%0APREFIX+census%3A+%3Chttp%3A%2F%2Fwww.rdfabout.com%2Frdf%2Fschema%2Fcensus%2F%3E+%0D%0APREFIX+census1%3A+%3Ctag%3Agovshare.info%2C2005%3Ardf%2Fcensus%2Fdetails%2F100pct%2F%3E+%0D%0A%0D%0ADESCRIBE+%3Ftable+WHERE+%7B+%0D%0A+%3Chttp%3A%2F%2Fwww.rdfabout.com%2Frdf%2Fusgov%2Fgeo%2Fcensus%2Fzcta%2F";
            //String requestPart2 = "" + zip; // zipcode goes here
            //String requestPart3 ="%3E+census%3Adetails+%3Fdetails+.+%0D%0A+%3Fdetails+census1%3AtotalPopulation+%3Ftable+.+%0D%0A+%3Ftable+dc%3Atitle+%22SEX+BY+AGE+%28P012001%29%22+.+%0D%0A%7D%0D%0A&outputMimeType=text%2Fxml";
              String requestPart1 = "" + zip;
            String response = "";
            URL url = new URL("http://www.melissadata.com/lookups/zipdemo2000.asp?ZipCode="+requestPart1);
            URLConnection conn = url.openConnection();
            // Set connection parameters.
            conn.setDoInput (true);
            conn.setDoOutput (true);
            conn.setUseCaches (false);
            // Make server believe we are form data…
            conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
            DataOutputStream out = new DataOutputStream (conn.getOutputStream ());
            // Write out the bytes of the content string to the stream.
            out.writeBytes(requestPart1);
            out.flush ();
            out.close ();
            // Read response from the input stream.
            BufferedReader in = new BufferedReader (new
            InputStreamReader(conn.getInputStream ()));
            String temp;
            while ((temp = in.readLine()) != null)
                 response += temp + "\n"; // needs to be parsed to calculate the 4 numbers
            temp = null;
            in.close ();
              //System.out.println("Server response:\n" + response);
              // how to call the method:
              String[] ages = {"Under 5 years", "5 to 9 years", "10 to 14 years", "15 to 17 years"};
              String[] ages1 = {"Under 5 years"};
              String[] ages2 = {"5 to 9 years"};
              String[] ages3 = {"10 to 14 years"};
              String[] ages4 = {"15 to 17 years"};
              String female1 = Arrays.toString(findValues(response, "female", ages1));
              String female2 = Arrays.toString(findValues(response, "female", ages2));
              String female3 = Arrays.toString(findValues(response, "female", ages3));
              String female4 = Arrays.toString(findValues(response, "female", ages4));
              String female = female1 + "+" + female2 + "<" + female3 + ">" + female4 + "&";
              String male1 = Arrays.toString(findValues(response, "male", ages1));
              String male2 = Arrays.toString(findValues(response, "male", ages2));
              String male3 = Arrays.toString(findValues(response, "male", ages3));
              String male4 = Arrays.toString(findValues(response, "male", ages4));
              String male = male1 + "+" + male2 + "<" + male3 + ">" + male4 + "&";
              System.out.println(female);
              System.out.println(male);
            //Simplified string response, makes use of regular expressions
            //Start manipulation of numbers inside string
            int left = female.indexOf("[");
              int right = female.indexOf("]");
              // pull out the text inside the parens
              String parsed = female.substring(left+1, right);
              double parseddub = Double.parseDouble(parsed);
              //divide the group Under5Years into Under12Mo and 1to4Yr
              double Group1Adub = parseddub*.25;//25% for Under12Mo
              Group1Adub = Math.ceil(Group1Adub);
              int Group1A =(int)Group1Adub;
              double Group1Bdub = parseddub*.75;//75% for 1to4Yr
              Group1Bdub = Math.ceil(Group1Bdub);
              int Group1B =(int)Group1Bdub;
              int left2 = female.indexOf("+");
              int right2 = female.indexOf("<");
              // pull out the text inside the parens
              String parsed2 = female.substring(left2+2, right2-1);
              double parsed2dub = Double.parseDouble(parsed2);
              //divide the group 5to9Yr into 5Yr, 6to7Yr, and 8to9Yr
              double Group2Adub = parsed2dub*.2;//20% for 5Yr
              Group2Adub = Math.ceil(Group2Adub);
              int Group2A =(int)Group2Adub;
              double Group2Bdub = parsed2dub*.4;//40% for 6to7Yr
              Group2Bdub = Math.ceil(Group2Bdub);
              int Group2B =(int)Group2Bdub;
              double Group2Cdub = parsed2dub*.2;//20% for 8Yr
              Group2Cdub = Math.ceil(Group2Cdub);
              int Group2C =(int)Group2Cdub;
              double Group2Ddub = parsed2dub*.2;//20% for 9Yr
              Group2Ddub = Math.ceil(Group2Ddub);
              int Group2D =(int)Group2Ddub;
              int left3 = female.indexOf("<");
              int right3 = female.indexOf(">");
              // pull out the text inside the brackets
              String parsed3 = female.substring(left3+2, right3-1);
              int Group3A = Integer.valueOf(parsed3).intValue();
              int left4 = female.indexOf(">");
              int right4 = female.indexOf("&");
              // pull out the text inside the brackets
              String parsed4 = female.substring(left4+2, right4-1);
              int Group4A = Integer.valueOf(parsed4).intValue();
              int left5 = male.indexOf("[");
              int right5 = male.indexOf("]");
              String parsed5 = male.substring(left5+1, right5);
              double parsed5dub = Double.parseDouble(parsed5);
              //divide the group Under5Years into Under12Mo and 1to4Yr
              double Group5Adub = parsed5dub*.25;//25% for Under12Mo
              Group5Adub = Math.ceil(Group5Adub);
              int Group5A =(int)Group5Adub;
              double Group5Bdub = parsed5dub*.75;//75% for 1to4Yr
              Group5Bdub = Math.ceil(Group5Bdub);
              int Group5B =(int)Group5Bdub;     
              int left6 = male.indexOf("+");
              int right6 = male.indexOf("<");
              // pull out the text inside the parens
              String parsed6 = male.substring(left6+2, right6-1);
              double parsed6dub = Double.parseDouble(parsed6);
              //divide the group 5to9Yr into 5Yr, 6to7Yr, and 8to9Yr
              double Group6Adub = parsed6dub*.2;//20% for 5Yr
              Group6Adub = Math.ceil(Group6Adub);
              int Group6A =(int)Group6Adub;
              double Group6Bdub = parsed6dub*.4;//40% for 6to7Yr
              Group6Bdub = Math.ceil(Group6Bdub);
              int Group6B =(int)Group6Bdub;
              double Group6Cdub = parsed6dub*.2;//20% for 8Yr
              Group6Cdub = Math.ceil(Group6Cdub);
              int Group6C =(int)Group6Cdub;
              double Group6Ddub = parsed6dub*.2;//20% for 9Yr
              Group6Ddub = Math.ceil(Group6Ddub);
              int Group6D =(int)Group6Ddub;
              int left7 = male.indexOf("<");
              int right7 = male.indexOf(">");
              // pull out the text inside the brackets
              String parsed7 = male.substring(left7+2, right7-1);
              int Group7A = Integer.valueOf(parsed7).intValue();
              int left8 = male.indexOf(">");
              int right8 = male.indexOf("&");
              // pull out the text inside the brackets
              String parsed8 = male.substring(left8+2, right8-1);
              int Group8A = Integer.valueOf(parsed8).intValue();
              //female
              int Group1 = Group1A;
              int Group2 = Group1B + Group2A;
              int Group3 = Group2A + Group2B + Group2C;
              int Group4 = Group2C + Group2D + Group3A + Group4A;     
              //male
              int Group5 = Group5A;
              int Group6 = Group5B + Group6A;
              int Group7 = Group6A + Group6B + Group6C;
              int Group8 = Group6C + Group6D + Group7A + Group8A;
              System.out.println("Server response:\n" + "\n" + "Female");
              System.out.println("Under 12 Months:    " + Group1);
              System.out.println("1 to 4 Years Old:   " + Group2);
              System.out.println("5 to 8 Years Old:   " + Group3);
              System.out.println("8 to 17 Years Old:  " + Group4);
              System.out.println("\n" + "Male");
              System.out.println("Under 12 Months:    " + Group5);
              System.out.println("1 to 4 Years Old:   " + Group6);
              System.out.println("5 to 8 Years Old:   " + Group7);
              System.out.println("8 to 17 Years Old:  " + Group8);
    }Currently it functions using a regex, and executes, but doesn't return any numbers, only returns zeros...If you could help me out with this, that would be amazing! Thanks so much.

    hmm, is there a way to do it without an external API? Of course there is.
    looks like i have to download the API and the idea behind the program is to make it so multiple people running only java can run the program, without having to download APIs, ect, to make it run. Not sure if that is what JTidy entails, but is that what you were suggesting?Personally, I don't understand the resistance to using well-tested tools already in existence as opposed to trying to rewrite a shallow facsimile of said tools. You can distribute the JTidy library along with your application and save yourself a great deal of development and debugging effort.
    ~

  • How to parse out curly quotes from a string

    Hi,
    I am writing a web application, where people will be copying from a Word Document into a text area. Then I get a String from the parameter passed.
    How can I parse out curly quotes and mdashes from this String? Are there specific character codes that I can parse out to replace them with regular quote characters or html quote characters?
    Thanks,
    Gabe

    Interesting problem and one that we had to deal with a couple of years ago. I think you might be talking about smart quotes and these are actually control characters used by MS products. They show up as squares in HTML unless properly dealt with. Try downloading some UNICODE charts to find out the values of these characters. I think they are something like 0044 and 0042 but I cannot remember off hand.

  • How to parse the date value for the string 2003-04-25 11:53:11 IST

    This is my database output for the date value(2003-04-25 11:53:11 IST). How to convet this string to Timestamp date value. Any one pl. help me

    BUT ... there is a public static Timestamp valueOf(String s) method in the Timestamp class that might help.
    http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Timestamp.html#valueOf(java.lang.String)

  • Problem while unzipping the non-ascii characters

    we are not able to retain the greek characters after zipping the files(that contain greek characters). the following code shows u a clear sketch about how we are zipping the files on solaris platform.
    ZipOutputStream out = null;
         try
              FileOutputStream f = new FileOutputStream(zipFileName);
              out = new ZipOutputStream(new BufferedOutputStream(f));
              for(int i = 0; i < fileNameLists.getNumElements(); i++)
                   BufferedReader in =     new BufferedReader(     new FileReader(fileNameLists.getNameAt(i)) );
                   out.putNextEntry(new ZipEntry(getFileName(fileNameLists.getNameAt(i))));
                   int c;
                   while((c = in.read()) != -1)
                        out.write(c);
                        in.close();
              out.close();
    if we are directly open the file which is stored in specified location its displaying greek characters(non-ascii) correctly but our application need to zip those files and save on windows platform.
    so once we zip the files and download onto windows platform its and extract the files its shows some garbage characters(may be using defaulr character encoding of windows cp1252) instead of greek charcaters.
    we tried in many ways using the setEncoding() method in ZipOutPutStream even then no use.
    is it because that zip utility while reading takes default character encoding of the platform?
    wud be thankful if anyone cud provive solution for this

    String encodingFormat = "UTF-8";
    BufferedReader in = new BufferedReader( new FileReader(fileNameLists.getNameAt(i)), encodingFormat );try the above code n let me know if its helpful

  • Replacing non-ascii characters in String

    I have a site where the user enters data in a rich text
    editor (ktml4) that gets stored into a database (mysql). There are
    non ascii characters getting into the data, I'm assuming that they
    are copying and pasting from Word. Unfortunately in this situation,
    changing that process isn't an option.
    Currently, this is the only character that is causing me
    problems:
    http://www.zvon.org/other/charSearch/PHP/search.php?request=ffa0&searchType=3
    I would just like to replace the non-ascii characters with a
    space when I read them from the database. Something like:
    #Replace(result.column, '\xffa0', ' ')#
    However, I believe that code looks for the string "\xffa0",
    not the character \xffa0.
    Is there anyway to do this?

    quote:
    Originally posted by:
    BuckLemke
    quote:
    Originally posted by:
    Dan Bracuk
    rereplace might work.
    Can you give an example of how to pass a non-ascii character
    to REReplace?
    Regular expressions are not my strength, but the approach I
    was considering was, "if it's not an ascii character, make it a
    space". Then you pass the entire string at once.

  • How to create a native KeyEvent for non ASCII characters

    Hello
    i need to create a native KeyEvent with my application. I know that it is possible to send such a event with the Robot-Class. But how do i send an event for a none ASCII character such as the german � (O with Diaeresis)?
    I also know that a combination of KeyEvent.VK_DEAD_DIAERESIS + KeyEvent.VK_O will get me the desired result, but i want just to pass the charachter � and let Java create the correct KeyCode(s).
    Does anyone knows a solution?
    BTW: AWTKeyStroke always returns 0 for the �
    Thanks
    Matt

    Hi, James.
    Unfortunately, none of the F-keys can be set to the functions of the Volume keys using the Keyboard Shortcuts preference pane.
    Mac OS X does not include native support for assigning a macro or script to either an Fkey or other keyboard shortcut. For that, you need a third-party tool, like iKey, Quickeys, or Spark, the latter suggested by DPSG-Scout.
    You'd also need a set of scripts to assign to the keys, e.g. scripts to increase, decrease, or mute the volume. Those are tricky to write since System Preferences does not expose much to AppleScript. One would need to use the "GUI Scripting (System Events)" technique to create a script to change the settings in the Sound preferences pane of System Preferences.
    Automator does offer a "Set Computer Volume" action, which allows you to adjust the various Volume settings (Output volume, Alert Volume, Input Volume) to a specific set of levels, including Mute for Output Volume. However, it won't handle the idea of pressing the same key multiple times to either increase or decrease the volume, ala the Volume Adjustment keys. In your case, it's most useful for Mute. Automator Workflows can be saved as applications, which I believe can then be assigned to Fkeys in iKey or QuickKeys.
    Someone may have written a more advanced Automator action for adjusting volume than that provided with Mac OS X. Search Apple's Automator Action Downloads. If you find one, instructions on adding actions to Automator can be found in Automator Help.
    You could search ScriptBuilders to see if someone has already written scripts for the functions you need, then use iKey or Quickeys to assign such to keyboard shortcuts.
    Finally, you could solve the problem another way: buy a set of external speakers that has its own separate volume and mute control. For example, my trusty old Monsoon MM1000s have their own volume control with a mute button.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • Replacing non-ASCII characters with HTML charcter references

    Hi All,
    In Oracle 10g or greater is there a built-in function that will convert a string with non-ASCII characters like this
    a b č 뮼
    into an ASCII string with HTML character references like this?
    a b & # x 0 1 0 D ; & # x B B B C ;
    (note I had to include spaces between each character in the sample code for message to prevent the forum software from converting my text)
    I tried using
    utl_i18n.escape_reference( val, 'us7ascii' )
    but for some reason it returns
    a b c & # x B B B C ;
    Note how it converted the Western European character "č" to its unaccented counterpart "c", not "& # x 0 1 0 D ;" (is this a bug?).
    I also tried a custom solution using regexp_replace and asciistr (which I can't include here because the forum software chokes on it) but it only returns the correct result for values <=4000 characters long. Unfortunately asciistr doesn't appear to accept CLOB values larger than 4000 characters. It returns an error message like
    (ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 30251, maximum: 4000) ).
    I'm looking for a solution that works on CLOB data of any size.
    Thanks in advance for any insight you can provide.
    Joe Fuda

    So with that (UTF8) in mind, let's take another look.....
    As shown below, I used a AL32UTF8 database.
    Note: I did not use a unicode capable tool for querying. So I set console mode code page to 1250 just to have č displayed properly (instead of posing as an è).
    Also, as a result of using windows-1250 for client character set, in the val column and in the second select's ncr column (iso8859-1), è (00e8) has been replaced with e through character set conversion going from server back to client.
    Running the same code on a database with a db character set such as we8mswin1252, that doesn't define the č (latin small c with caron) character, would yield results with a c in the ncr column.
    C:\>chcp 1250
    Aktuell teckentabell: 1250
    C:\>set nls_lang=.ee8mswin1250
    C:\>sqlplus test/test
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri May 23 21:25:29 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the OLAP option
    SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET';
    PARAMETER              VALUE
    NLS_CHARACTERSET       AL32UTF8
    NLS_NCHAR_CHARACTERSET AL16UTF16
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'us7ascii') NCR from dual;
    VAL  NCR
    č e  c e
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'we8iso8859p1') NCR from dual;
    VAL  NCR
    č e  &# x10d; e     <- "è"
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'ee8iso8859p2') NCR from dual;
    VAL  NCR
    č e  č &# xe8;
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'cl8iso8859p5') NCR from dual;
    VAL  NCR
    č e  &# x10d; &# xe8;In the US7ASCII case, where it should be possible for all non-ascii characters to be escaped, it seems as if the actual escape step is skipped over.
    Hope this helps to understand whether utl_i8n is usable or not in your case.
    Message was edited by:
    orafad
    Fixed replaced character references :)

  • How to remove non-ASCII charcters from an XML generated using Simple Transf

    Hi,
    I am currently facing a problem where I invoke a ST like
    CALL TRANSFORMATION ZTEST
      source root = str
      result xml rawstr.
    to prepare an XML using the contents of the ABAP variable str.
    In my case sometime the variable str can contain non-ASCII characters. What I find is that ST do not remove these characters and the final XML that get generated thus contains non-parsable xml charcaters.
    Is there an efficient way to remove/replace such non-ascii characters within the ST such that my final XML is consumable by any xml parser. I do not want to do a second level of processing by running through the output xml and removing the charcaters individually, because in our system the number of xml messages generated is very high and any such lookup-replace algorithm terms out to be too coslty.
    Regards,
    Vikas Lamba

    Hi
    may be you know this syntax :)
    <?xdofx:substr(SHIP_TO_LOCATION_NAME,11,44)?>
    Rahul

  • When I try to send an email I get a message - Non ASCII characters in the local part of the recipient address.

    I am trying to send an emails to Italy. When I click send I get a message ( Non-ASCII characters in the local part of the recipient address). [email protected]  is one of the email address I am trying to send to. My other email address' work OK. I have sent emails to these Italian address before with no problem.

    Restart the operating system in '''[http://en.wikipedia.org/wiki/Safe_mode safe mode with Networking]'''. This loads only the very basics needed to start your computer while enabling an Internet connection. Click on your operating system for instructions on how to start in safe mode: [http://windows.microsoft.com/en-us/windows-8/windows-startup-settings-including-safe-mode Windows 8], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-7 Windows 7], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-vista Windows Vista], [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/boot_failsafe.mspx?mfr=true" Windows XP], [http://support.apple.com/kb/ht1564 OSX]
    ; If safe mode for the operating system fixes the issue, there's other software in your computer that's causing problems. Possibilities include but not limited to: AV scanning, virus/malware, background downloads such as program updates.

  • Problem searching some PDF files in Acrobat Reader – Non-ASCII characters

    Acrobat Reader cannot search some .pdf files.  I have put an example document up on Scribd here.
    Any attempt to search for any word that can be clearly seen to be in the document fails with “No matches were found.”
    This example document is NOT a scanned document – words and characters can be selected.
    A hex display tool shows that the characters in a PDF document that can be successfully searched are in the ASCII/1252 range (A=0x41, etc).
    Copying and pasting characters in the example document to a hex display tool shows that the characters in the document are not in the ASCII range.
    For example the letters A to Z in the example document are in the range ‘A’ = 0xDF (decimal 223), ‘B’ = 0xDE (decimal 222), through to ‘Z’ = 0xC6 (decimal 198).
    However, characters in these non-ASCII ranges are displayed perfectly by Acrobat Reader, as can be see if the example document is opened.
    Therefore, as Acrobat Reader knows what these characters are, it doesn’t seem unreasonable to say that it should be able to search for and find them.
    Tests were performed using Acrobat Reader X v10.1.4.
    Can anyone say what this problem is?

    Hi Pat, thanks for your reply. 
    Your reference to the title of that page being 'HARNESSES' indicates that, when you view that document in Adobe Reader, you are seeing 'HARNESSES', not
    "ØßÎÒÛÍÍÛÍ".  And that the remainder of the document is similarly being displayed in readable English language.
    Yes as you say, you can search for 'ß' and get hits on 'A' (to use that as an example) in the example document.
    But the need to form a word to be searched for into whatever code mapping this is using (for example having to enter "ØßÎÒÛÍÍ" for HARNESSES - I'm not even sure how that would be entered from a keyboard) doesn't seem to be very convenient.
    Its clear the example document is using some code mapping other than ASCII / Windows-1252 (which has 'A' as 0x41).  But it is also clear that Adobe Reader knows what that mapping is, and knows to use it, as its displaying (for example) 'A' for the code 0xDF. 
    So I guess the question is - why isn't Adobe Reader's knowledge of this mapping being extended to its search input? 

  • [SOLVED] KDEmod - problem with mounting b/c of non-ASCII characters

    Hi guys!
    I finally set aside a few gigabites for Archlinux - it is no more in a virtual machine So far I managed to configure everything with the excellent wiki. It's runnin' and kickin'. I run accross only one problem:
    When I insert a CD with a label that has non-ASCII characters (some Polish ones in my case) and I click on it's icon in Konqueror I get the message that "file such-and-such doesn't exist" - and the Polish characters are clearly misspelled (it is not a fonts' problem - I double checked). I can access the folder either via console or via konqueror if I go to the /media folder, though.
    Any ideas how I can fix it? If you need more info, let me know.
    Last edited by JeremyTheWicked (2008-05-31 14:46:07)

    You're welcome . Now it's advisable for you to edit the title of your initial post: add [SOLVED]. Perhaps more clear wording would be in order, too, for the benefit of the search engine. The problem seems to be a trifle in retrospect, but somehow it takes some effort to find the solution, doesn't it ?

  • Non-ASCII Characters Appear In Path Name

    I've had this happen before over SSH via PuTTY on a Windows Host but now it's happening just in Linux. I'm testing out my first attempt at remastering the Arch Live CD and my home directory never got created while running rc.local, when I tried to execute it manually I got block characters at the beginning and end of the path. I tried to type the command manually and got the same thing. I enabled en_US ISO-8859-1 along with en_US.UTF-8 UTF-8 in /etc/locale.gen and re-ran locale.gen but it didn't seem to fix my issue. Anyone have any idea on how to fix this?
    Last edited by brando56894 (2013-08-30 17:01:04)

    What do you mean by non-ASCII characters?
    The ASCII character set contains characters for all byte values, however not all of them are displayable characters. Is it non-displayable characters you want?

  • Removing Non-Ascii Characters from a String

    Hi Everyone,
    I would like to remove all NON-ASCII characters from a large string. For example, I am taking text from websites and would like to remove all the strange arabic and asian characters. How can I accomplish this?
    Thank you in advance.

    I would like to remove all NON-ASCII characters from a large string. I don't know if its a good method but try this:
    str="\u6789gj";
    output="";
    for(char c:str.toCharArray()){
         if((c&(char)0xff00)==0){
              output=output+c;
    System.out.println(output);
    all the strange arabic and asian characters.Don't call them so.... I am an Indian Muslim ;-) ....
    Thanks!

Maybe you are looking for