Dealing with escape characters

I have a command that works if I represent it as "\003"+command+"\r" because my command needs to be preceded by the char 'x03' and tailed by the char 'x0d'. The literals "\003" and "\r" are being converted as I wish into their equivalent byte values.
If I use Java string variables 'start' and 'end' to hold the values "\003" and "\r" and I issue my command as 'start+command+end', the start and end values are NOT converted into byte values. They remain represented as they are written i.e my string command is preceded by '\003' and ends with '\r'.
How can I convert escape characters stored in string variable into their byte equivalents?
David

Please show us the code, because what you say isn't clear. If the Strings are written as
String start = "\003";  // etx
String end = "\r";   //crIt should work.
Often this sort of thing is easier to do with character variable. eg.
char start = 3;  // etx
char end = 13;  // crI also wonder why you are using etx (end of text) as the start of text, the usual choice would be stx=\002. Also, none of this has anything to do with "byte" values, they are characters and take 2 bytes each. Your network code can do that conversion for you after you choose your character set. Is it UTF8, Latin-1, or some other.

Similar Messages

  • How to deal with escaping characters?

    Using SQLDeveloper v1.2.0 with Oracle 9i.
    I'm converting a sql script that used to use Jakarta Jelly syntax (xml). I'm replacing it with a pure SQL syntax so I can execute it directly in both SQLDeveloper and SQLPlus. The text in the row data has a bunch of occurrences of special characters that I need to escape somehow, to avoid prompting and other issues.
    I tried replacing strings like "a & b" with "a \& b". My script begins like the following:
    set pagesize 0
    set echo off
    set verify off
    set feed off
    set prompt off
    set head off
    set line 200
    set esc on \
    truncate table <tablename>;
    However, when I run the script, it still prompts me when it finds a string like "... \& ...".
    What can I do to get this to work in SQLDeveloper, and to work in SQLPlus at the same time?

    Actually, the SCAN system variable was obsoleted by DEFINE.
    Ref: http://download.oracle.com/docs/cd/B10501_01/server.920/a90842/apc.htm
    So SET DEFINE OFF would have the same effect without any possible compatibility issues.
    However, that would disable DEFINEs/substitution variables altogether. If, you want to escape specific instances of the DEFINE character (&), you would have to go with your SET ESC[APE] approach.
    Now, the syntax for that is SET ESC[APE] {\|c|ON|OFF}.
    Ref: http://download.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1012530
    So, you'd want to use either...
    set esc on
    ... or...
    set esc /
    ... and not both options (ON as well as /).
    But (and here's where it gets really interesting!) there seems to be a problem in how SQL Developer handles the SET command with the ESCAPE system variable. If you try to set ESCAPE to the same character two times in immediate sequence within the same Worksheet, the whole Worksheet goes berserk and every subsequent SQL statement hrows a SQL Error: ORA-00900: invalid SQL statement!
    I sense a bug!

  • Issue with escaping characters and php

    Greetings,
    We are working on a web page using php and Oracle. We have troubles dealing with the diferent escaping characters when inserting/retrieving data (magic quotes is on but adding the backslash doesn't help :( ).
    We would like to know the correct way of dealing with those characters ( ' " / /n ...).
    Thank you in advance,
    Sincerely,
    Oriol Nonell

    Do NOT use addslashes/stripslashes to escape your queries. I use this function to do the escaping:
    function escapeSQL($string, $wildcard=false)
    $result = str_replace("'","''",$string);
    if ($wildcard == true) $result = str_replace("%","%%",$result);
    return $result;
    It basically replaces ' with ''.
    If you set $wildcard to false, then '%' is considered to be an actual '%' (for 'like' expressions). If you set it to true, a % is escaped to %% too.

  • Web Logic 10.3 upgrade causes issues with escaped characters in JSP.

    We recently upgraded our application servers from Weblogic 9.2 to Weblogic 10.3 and we are having an issue with escaped characters in a JSP code. Here is an example of what we are seeing:
    var convertedBody1 = document.getElementById('body').value.replace(/\$FIRST_NAME\$/g, firstName);
    This code works in Weblogic 9.2. In Weblogic 10.3 we have to make the following changes:
    var convertedBody1 = document.getElementById('body').value.replace(/\$FIRST_NAME\$/g, firstName);
    Thanks, Tom

    Hi:
    I have resolved the issue with the following in the jspx page.
    Put an
    <jsp:scriptlet>
    response.setContentType(“text/html; charset=UTF-8”);
    </jsp:scriptlet>
    Inside the <f:view> on the jspx file.
    Please refer the link http://www.oracle.com/global/il/support/tip/nlss11061.html for more details. It is helpful.
    Thanks & Regards
    Sridhar Doki

  • Can Java deal with Roman characters correctly ?

    I am making a Java programme to insert some Roman characters such as TUV (multibyte) to Oracle8.1.7 database .
    Database character set is JA16EUC .
    As soon as I inserted those letters into the database , the letters will become ??? , why ?
    As I have used a Oracle8i tool named nativa2ascii to make similar transmition , but failed ?
    So I'd say , Java presently (SDK1.3.1) cannot deal with this situation , right ?
    Thank you for your great kindness !

    I don't want to uncompress the file.
    The idea of dealing with a compressed file is to hopefully save overhead that reading a big file has. I want to manipulate the data internaly without uncompressing the file. I can do it with a zip file but my 15M text file become 2M with zip and 96K with rar file. A huge difference.

  • Dealing with special characters

    Hello Guys,
    I have some time finding for solutions trying to filter out the columns with occurence of special character.
    Can anybody help me build a query to trap/filter colums with occurence of unwanted any_+ special characters?
    A syntax for finding any special characters would do.
    I am using Oracle SQL Developer Version 1.5.5.
    Thanks...
    Edited by: ard565 on Jan 26, 2010 7:06 PM

    Hi,
    Can you provide the structure of the table, and do you want to filter the record if special character occurs on any column of the table or any particular column.
    Moreover in your terms what does special character stands for. Is it all the character that is not alpha numeric or specific set of special character?
    Regards
    Anurag

  • Creating XML DOM with Escape characters

    I am using DOM to generate xml fie. Setting some chinese character string which is hardcoded for one of node value.
    When i am setting value to xml node i am passing it as "&#x2206;" but DOM automatically converts this string and store into xml file as "&#x2206"
    Because of this i can not show proper chinese characters in PDF. How i can avoid this ? Is it possible to store chinese character as "&#x2206" itself inside xml?
    regards
    Manisha

    When setting the value from java you can use the real unicode character. Assuming with &#2206; you want to write the Unicode-Character at Codepoint 0x2206 you could just use "\u2206" in a java String to encode it. The XML library has to take care of how it's encoded in the final xml file.

  • XML context search with escape characters

    Hi,
    I have a piece of XML in an XMLTYPE column which is context indexed. The xml looks like
    &lt;content&gt;
    &lt;EndDate/&gt;
    &lt;Councillor&gt;Smith John&lt;/Councillor&gt;
    &lt;Committee&gt;Inspection Leader&amp;#039;s Advisory Body &lt;/Committee&gt;
    &lt;StartDate/&gt;
    &lt;LinkType&gt;Committee Link&lt;/LinkType&gt;
    &lt;Text/&gt;
    &lt;/content&gt;
    My query which escapes the search field between {} is
    select xmlType.getStringVal(xmlType.extract(CI.CONTENT_XML,'/content/Committee/text()')) Committee
    from CMPS.CM$CONTENT_ITEMS CI
    where CONTAINS(content_xml,'{Inspection&a} INPATH(/content/Committee)') &gt; 0
    returns the row successfully
    However
    select xmlType.getStringVal(xmlType.extract(CI.CONTENT_XML,'/content/Committee/text()')) Committee
    from CMPS.CM$CONTENT_ITEMS CI
    where CONTAINS(content_xml,'{Inspection&am} INPATH(/content/Committee)') &gt; 0
    --Note the extra character in between {}
    does not return anything.
    Can someone tell me if I am escaping the reserved characters correctly?
    Is there something that I missed when I created my index i.e
    CREATE INDEX CIM_CONTEXT ON
    cm$content_items(content_xml) indextype is ctxsys.context;
    I am running 9.2.0.4 on RED HAT 3.
    Thanks
    Joel.

    From the text team...
    The default section group for XMLType column is path section group.
    As for his question, the reason why he gets a hit for the first query:
    {Inspection&a} INPATH(/content/Committee), is because {Inspenction&a} is lexed as
    a phrase "Inspection a" and a by default is 'a' stop word.
    And {Inspection&am} is lexed as a phrase "Inspection am". Since there is no such phrase ("am" is not a stop word), the query does not return the row.
    If he tries {Inspection&an}, he will get the row because "an" is again by default a stop word.
    The behavior is independent of INPATH operator. He will see the same behavior without INPATH operator:
    select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&a}') > 0;
    select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&am}') > 0;
    select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&an}') > 0;
    Note sure I understand it but I hope it helps

  • Dealing with special characters in  PHP part deux

    Something else is confusing me about special characters.  I am doing some troubleshooting/maintenaince on my files. On one files I have my navigation bar on a separte file and use the include function to use it. 
    For the other file, I took the include out and just copy and pasted what was in the inculde file directly on to the file. 
    The words that contain special characters in the include appear funny in the browser. However the menu that is not included (but copied from the include) appears normal.
    Any thoughts?
    One is copied and pasted from the other, yet the look different

    Sorry, my head's been swimming today:
    Here is the include file (minus much of the list)
    The Beers
    Recent Additions
    Recommended
    Hybrid        
    06 Light Hybrid            
    06a Cream Style
    06b Blonde Ale
    06c Kölsch
    06d American Wheat/Rye
    07 Amber Hybrid            
    07a Northern German Altbier
    07b California Common
    07c Düsseldorf Altbier
    And the above include is put in here:
    This is all the code north of the content.
    Also, all I did to copy and paste this was hit ctrl A and crtl C on the sidebar include page, and ctrl V on the file below.
    <?php require_once('Includes/connection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    ?>
    <?php require_once('Includes/mysql_prep.php'); ?>
    <?php
    $colname_DetailRS1 = "-1";
    if (isset($_GET['listID'])) {
      $colname_DetailRS1 = $_GET['listID'];
    mysql_select_db($database_beer_diary, $beer_diary);
    $query_list_beer = sprintf("SELECT * FROM beer ORDER BY date_tasted_01 DESC LIMIT 15", GetSQLValueString($colname_DetailRS1, "text"));
    $list_beer = mysql_query($query_list_beer, $beer_diary) or die(mysql_error());
    $row_list_beer = mysql_fetch_assoc($list_beer);
    $total_rows = mysql_num_rows($list_beer);
    ?>
    <html>
    <head>
    <title>Recent Additions</title>
    <link href="stylesheets/style.css" rel="stylesheet" type="text/css" />
    <link href="stylesheets/table_and_forms.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="images/beer.jpg">
    </head>
    <body>   
    <div id="container">
    <div id="header">
    <?php include('Includes/header.php');?>
    </div>
    <div id="sidebar">   
    <!----------------SPRY NAVIGATION MENU CODE FOR FORMS-------------------------------------------------------------->
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css">
    <ul id="Beer_Navi" class="MenuBarVertical">
    <h1>The Beers</h1>
    <li><a href="recent_list.php">Recent Additions</a></li>
          <li><a href="recommend_list.php">Recommended</a></li>
          <li><a class="MenuBarItemSubmenu" href="#">Beer by Country</a>
            <ul>
              <li><a href="country_list.php?listID=USA">America</a></li>
              <li><a href="country_list.php?listID=BEL">Belgium</a></li>
              <li><a href="country_list.php?listID=DEU">Germany</a></li>
              <li><a href="country_list.php?listID=GBR">Great Britain</a></li>
              <li><a href="country_list.php?listID=JPN">Japan</a></li>
              <li><a href="oth_list">Other Countries</a></li>
            </ul>
      </li>
          <li><a href="#" class="MenuBarItemSubmenu">Lager</a>
            <ul>
              <li><a href="style_list.php?listID=01">01 Light Lager</a>
                <ul>
                  <li><a href="substyle_list.php?listID=01a">01a Lite American Lager</a></li>
                  <li><a href="substyle_list.php?listID=01b">01b Standard American Lager</a></li>
                  <li><a href="substyle_list.php?listID=01c">01c Premium American Lager</a></li>
                  <li><a href="substyle_list.php?listID=01d">01d Munich Helles</a></li>
                  <li><a href="substyle_list.php?listID=01e">01e Dortmunder Export</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=02">02 Pilsner</a>
                <ul>
                  <li><a href="substyle_list.php?listID=02a">02a German Pilsner (Pils)</a></li>
                  <li><a href="substyle_list.php?listID=02b">02b Bohemian Pilsner</a></li>
                  <li><a href="substyle_list.php?listID=02c">02c Classic American Pilsner</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=03">03 European Amber Larger</a>
                <ul>
                  <li><a href="substyle_list.php?listID=03a">03a Vienna Lager</a></li>
                  <li><a href="substyle_list.php?listID=03b">03b Oktoberfest/Märzen</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=04">04 Dark Lager</a>
                <ul>
                  <li><a href="substyle_list.php?listID=04a">04a Dark American Lager</a></li>
                  <li><a href="substyle_list.php?listID=04b">04b Munich Dunkel</a></li>
                  <li><a href="substyle_list.php?listID=04c">04c Schwarzbier</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=05">05 Bock</a>
                <ul>
                  <li><a href="substyle_list.php?listID=05a">05a Maibock/Helles Bock</a></li>
                  <li><a href="substyle_list.php?listID=05b">05b Traditional Bock</a></li>
                  <li><a href="substyle_list.php?listID=05c">05c Doppelbock</a></li>
                  <li><a href="substyle_list.php?listID=05d">05d Eisbock</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Hybrid</a>
            <ul>
              <li><a href="style_list.php?listID=06">06 Light Hybrid</a>
                <ul>
                  <li><a href="substyle_list.php?listID=06a">06a Cream Style</a></li>
                  <li><a href="substyle_list.php?listID=06b">06b Blonde Ale</a></li>
                  <li><a href="substyle_list.php?listID=06c">06c Kölsch</a></li>
                  <li><a href="substyle_list.php?listID=06d">06d American Wheat/Rye</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=07">07 Amber Hybrid</a>
                <ul>
                  <li><a href="substyle_list.php?listID=07a">07a Northern German Altbier</a></li>
                  <li><a href="substyle_list.php?listID=07b">07b California Common</a></li>
                  <li><a href="substyle_list.php?listID=07c">07c Düsseldorf Altbier</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Ales</a>
            <ul>
              <li><a href="style_list.php?listID=08">08 English Pale Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=08a">08a Standard/Ordinary Bitter</a></li>
                  <li><a href="substyle_list.php?listID=08b">08b Special/Best/Premium</a></li>
                  <li><a href="substyle_list.php?listID=08c">08c Extra Special/Strong</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=09">09 Scottish & Irish Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=09a">09a Scottish Light 60/-</a></li>
                  <li><a href="substyle_list.php?listID=09b">09b Scottish Heavy 70/-</a></li>
                  <li><a href="substyle_list.php?listID=09c">09c Scottish Export 80/-</a></li>
                  <li><a href="substyle_list.php?listID=09d">09d Irish Red Ale</a></li>
                  <li><a href="substyle_list.php?listID=09e">09e Strong Scotch Ale</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=10">10 American Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=10a">10a American Pale Ale</a></li>
                  <li><a href="substyle_list.php?listID=10b">10b American Amber Ale</a></li>
                  <li><a href="substyle_list.php?listID=10c">10c American Brown Ale</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=11">11 English Brown Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=11a">11a Mild</a></li>
                  <li><a href="substyle_list.php?listID=11b">11b Southern English Brown</a></li>
                  <li><a href="substyle_list.php?listID=11c">11c Northern English Brown</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=12">12 Porter</a>
                <ul>
                  <li><a href="substyle_list.php?listID=12a">12a Brown Porter</a></li>
                  <li><a href="substyle_list.php?listID=12b">12b Robust Porter</a></li>
                  <li><a href="substyle_list.php?listID=12c">12c Baltic Porter</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=13">13 Stout</a>
                <ul>
                  <li><a href="substyle_list.php?listID=13a">13a Dry Stout</a></li>
                  <li><a href="substyle_list.php?listID=13b">13b Sweet Stout</a></li>
                  <li><a href="substyle_list.php?listID=13c">13c Oatmeal Stout</a></li>
                  <li><a href="substyle_list.php?listID=13d">13d Foreign Extra Stout</a></li>
                  <li><a href="substyle_list.php?listID=13e">13e American Stout</a></li>
                  <li><a href="substyle_list.php?listID=13f">13f Russian Imperial Stout</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=14">14 India Pale Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=14a">14a English IPA</a></li>
                  <li><a href="substyle_list.php?listID=14b">14b American IPA</a></li>
                  <li><a href="substyle_list.php?listID=14c">14c Imperial IPA</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=15">15 German Wheat & Rye</a>
                <ul>
                  <li><a href="substyle_list.php?listID=15a">15a Weizen/Weissbiet</a></li>
                  <li><a href="substyle_list.php?listID=15b">15b Dunkelweizen</a></li>
                  <li><a href="substyle_list.php?listID=15c">15c Weizenbock</a></li>
                  <li><a href="substyle_list.php?listID=15d">15d Roggenbeir (Rye)</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=16">16 Belgian & French Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=16a">16a Witbier</a></li>
                  <li><a href="substyle_list.php?listID=16b">16b Belgian Pale Ale</a></li>
                  <li><a href="substyle_list.php?listID=16c">16c Saison</a></li>
                  <li><a href="substyle_list.php?listID=16d">16d Bière de Garde</a></li>
                  <li><a href="substyle_list.php?listID=16e">16e Belgian Specialty Ale</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=17">17 Sour Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=17a">17a Berliner Weisse</a></li>
                  <li><a href="substyle_list.php?listID=17b">17b Flanders Red Ale</a></li>
                  <li><a href="substyle_list.php?listID=17c">17c Flanders Brown Ale</a></li>
                  <li><a href="substyle_list.php?listID=17d">17d Straight Lambic</a></li>
                  <li><a href="substyle_list.php?listID=17e">17e Gueuze</a></li>
                  <li><a href="substyle_list.php?listID=17f">17f Fruit Lambic</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=18">18 Belgian Strong Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=18a">18a Belgian Blond Ale</a></li>
                  <li><a href="substyle_list.php?listID=18b">18b Belgian Dubbel</a></li>
                  <li><a href="substyle_list.php?listID=18c">18c Belgian Tripel</a></li>
                  <li><a href="substyle_list.php?listID=18d">18d Belgian Golden Strong Ale</a></li>
                  <li><a href="substyle_list.php?listID=18e">18e Belgian Dark Strong Ale</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=19">19 Strong Ale</a>
                <ul>
                  <li><a href="substyle_list.php?listID=19a">19a Old Ale</a></li>
                  <li><a href="substyle_list.php?listID=19b">19b English Barleywine</a></li>
                  <li><a href="substyle_list.php?listID=19c">19c American Barleywine</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Specialty Beers</a>
            <ul>
              <li><a href="style_list.php?listID=20">20 Fruit Beer</a></li>
              <li><a href="style_list.php?listID=21">21 Spice/Herb/Vegetable Beer</a>
                <ul>
                  <li><a href="substyle_list.php?listID=21a">21a Spice, Herb, or Vegetable</a></li>
                  <li><a href="substyle_list.php?listID=21b">21b Christmas/Winter Specialty</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=22">22 Smoked/Wood-aged Beer</a>
                <ul>
                  <li><a href="substyle_list.php?listID=22a">22a Classic Rauchbeir</a></li>
                  <li><a href="substyle_list.php?listID=22b">22b Other Smoked Beer</a></li>
                  <li><a href="substyle_list.php?listID=22c">22c Wood-Aged Beer</a></li>
                </ul>
              </li>
              <li><a href="style_list.php?listID=23">23 Specialty Beer</a></li>
            </ul>
          </li>
    </ul>
    <script type="text/javascript">
    <!--
    var MenuBar1 = new Spry.Widget.MenuBar("Beer_Navi", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    //-->
    </script>
    </div><!-- end #sidebar -->
    <div id="content">

  • Setting escape characters for a MySQL insertion

    Hello all. I'm trying to format an incoming string with escaped characters so I can insert them into a mysql database... a quick rundown would be
    ' replaced with \'
    " replaced with \"
    escaping newline characters with the literal text "\n" (without quotes)
    escaping arriage return characters with the literal text "\r" (without quotes)
    for some reason it's not working out. Here's the method I made to handle it:
      public static String mysqlEncode(String stringToEncode) {
        String returnString = stringToEncode;
        // Replace " with \"
        if (returnString.matches("\\\"")) returnString = returnString.replaceAll("\\\"", "\\\"");
        // Replace ' with \'
        if (returnString.matches("'")) returnString = returnString.replaceAll("'", "\\'");
        // Replace \ with \\
        if (returnString.matches("\\\\")) returnString = returnString.replaceAll("\\\\", "\\\\");
        // Replace newlines with \n
        if (returnString.matches("\\n")) returnString = returnString.replaceAll("\\n", "\\n");
        // Replace carriage returns with \r
        if (returnString.matches("\\r")) returnString = returnString.replaceAll("\\r", "\\r");
        return returnString;
      }and it keeps bombing out , I'm on my 3rd hour at this and it's really starting to irk me...
    questions:
    are my regular expressions formed correctly?
    is that if statement calling the .matches() method necessary?
    Thanks so much for your help.

    String sql = "SELECT * FROM MyTable WHERE author = ? AND text = ?";
    PreparedStatement pstm = connection.prepareStatement(sql);
    synchronized(pstm){  // if you're doing multithreading stuff (if single thread..you can ignore the synchronized
        pstm.clearParameters();
        pstm.setString(1, "Anne Rice");    //  1 = the first question mark in the String sql
        pstm.setString(2, "The Vampire Lestat's long fangs");
    ResultSet res = pstm.executeQuery();
    while (res.next()){
    }same thing for INSERT, UPDATE, etc..

  • Escape characters using Oracle JDBC

    We use Oracle JDBC driver to do some operations on an Oracle 9i database, and ran into some problems with escape characters. Basically we'd like to escape the _ and % characters.
    The following two example statements both work:
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' escape '\\' ");
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' {escape '\\' }");
    However, when we have multiple query terms and the "escape" clause doesn't immediately follows EACH "like" clause, we got errors saying the sql statement does not end properly. One such example is the following:
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' and creator = 'ABC' {escape '\\'} ");
    If we put an "escape" clause following each "like" clause, then it works.
    My question is, is there a smart way of letting JDBC knows that you want to use an escape character everywhere in the query? We often do very complicated dynamic queries, frequently with table joins and boolean logic and subqueries with tons of query terms. Trying to add the escape clause to each "like" clause is very painful. Any help is highly appreciated. Thanks!
    BL

    I'd use PreparedStatements, if you're not already. Let the JDBC driver escape things properly for you. That's what the setString() and setDate() methods are all about.

  • Escaping characters in SOAP Envelope XML string

    Hello,
    I have a manual web service reference (i.e. a XML String parametrized with more fields from my apex page). Sometimes the web service call fails because the user can enter special XML characters in the text field (this in consequence makes the XML String invalid XML). Do you know any elegant way to deal with this problem? Having a process that does htf.escape_sc for each text field in the same page I have my text field is a bit complcated in my case.
    Are there any other options?
    Many thanks in advance

    Hi "user11085282",
    you might try to wrap the user input in CDATA sections ... this is the "XML way" to have special characters in a document without escaping them. CDATA sections look
    as follows
    <tag><![CDATA[& & < <> >]]></tag>
    http://www.w3schools.com/xml/xml_cdata.asp
    Hope this helps ...
    Carsten Czarski
    Deutschsprachige APEX-Community: Tipps, Tricks, Best Practice
    http://tinyurl.com/apexcommunity
    SQL und PL/SQL: Tipps, Tricks & Best Practice
    http://sql-plsql-de.blogspot.com
    Twitter: @cczarski @oraclebudb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to deal with special character in source file

    Hi experts,
                      i am doing a file to file scenario in which my source file contains many special characters when i am puting this file into moni its going with the special character .My source file is a fixed length file so in content conversion i have specified the file length but due to these special charcters these field lenght is also varing.So please guide me how to deal with these special characters in sender adapter
    regards,
    Saurabh

    you could try using a Java Mapping to change the encoding manually. For that, set the encoding of the OutputFormat of the XML you'll serialize. Try the following code piece for the mapping (inside a try/catch declaration):
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = factory.newDocumentBuilder();
    Document input = documentBuilder.parse(in);
    OutputFormat format = new OutputFormat(XML, "ISO-8859-1", false);
    XMLSerializer serializer = new XMLSerializer(out, format);
    For more details check this guide:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • How can I use escaped-characters in an option

    I have the following code that is used to retrieve city-names including parent-child relations from a database and place them in an array:
    <%@ page contentType="application/x-javascript" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <sql:setDataSource dataSource="jdbc/KADOS" var="Raak" scope="session" />
    <sql:query var="bewaringSQL" dataSource="${Raak}">
    SELECT bewaringcode, vestigingsplaats FROM BEWARING order by vestigingsplaats
    </sql:query>
    bewaringen = new Array(
    <c:forEach items="${bewaringSQL.rows}" var="plaats" varStatus="s" >
    new Array( "<c:out value="${plaats.BEWARINGCODE}" />",
    "<c:out value="${plaats.VESTIGINGSPLAATS}" />" )
    <c:if test="${not s.last}">,</c:if>
    </c:forEach>
    i=0;
    <c:forEach items="${bewaringSQL.rows}" var="plaats" varStatus="s" >
    <sql:query var="bewaringGemSQL" dataSource="${Raak}" sql="SELECT KADGEMCODE, KGMNAAM FROM KADGEMEENTE where BEWARINGCODE=? order by KGMNAAM">
    <sql:param value="${plaats.BEWARINGCODE}" />
    </sql:query>
    tmp = new Array(
    <c:forEach items="${bewaringGemSQL.rows}" var="gem" varStatus="s" >
    new Array( "<c:out value="${gem.KGMNAAM}" />",
    "<c:out value="${gem.KADGEMCODE}" />" )
    <c:if test="${not s.last}">,</c:if>
    </c:forEach>
    bewaringen[2] = tmp;
    i = i+1;
    </c:forEach>
    function bewaringenList(selectCtrl, itemArray) {
    for (i=0; i<itemArray.length; i++) {
    selectCtrl.options[i] = new Option(itemArray[i][1]);
    selectCtrl.options[i].value = itemArray[i][0];
    function setList(selectCtrl, itemArray) {
    for (i=selectCtrl.options.length; i>=0; i--) {
    selectCtrl.options[i] = null;
    for (i=0; i<itemArray.length; i++) {
    optie = filter(itemArray[i][0]);
    selectCtrl.options[i] = new Option(optie);
    selectCtrl.options[i].value = itemArray[i][1];
    function filter( invoer) {
    retour = invoer;
    retour = retour.replace("'", "\'");
    return retour;
    The function 'bewaringenList' populates a <SELECT> with parent-names and
    "setList(document.VraagForm.gemSelect, bewaringen[this.selectedIndex][2]);" populates the depending <SELECT> with child-names.
    Some names contain single quotes (like "&#039;t Zandt") and are displayd in the select-box as "&#039t Zandt".
    I expected that the quotes could be replaced by escape-characters by 'filter(invoer)' but this does not work.
    Is there a generic way to show these characters?
    Ben

    I don't understand why but this filter solved the problem:
    function filter( invoer) {
    retour = invoer;
    retour = retour.replace("&#039;", "'");
    return retour;

  • Problem in dealing with special-character filename

    Hi,
    I am facing a weird problem while dealing with a file which has a special character in its name. That character is the big-hyphen, i.e. '–' (not the normal hyphen we can type from keyboard), you would have seen this character in MS Word.
    My java program is running on HP-UX OS, and its basically trying to copy this file to a Windows target system through socket. But while executing it, I am getting Broken Pipe Exception.
    I am applying UTF-8 encoding while running my program (by specifying the argument "-Dfile.encoding=UTF-8" in the java process), and I am also confirming that the file-encoding is being applied to UTF-8 properly by putting a debug in the beginning of the program. My understanding is UTF-8 supports all the characters exist in this world.
    Any suggestion / pointers would be really appreciated.
    Thanks,
    Rajiv

    Fine..... but is there any way to know which encoding has been applied on it ..
    Let's say if you create any file on unix-based system in any application, which encoding gets applied there by default ?
    This file is basically nothing but an html page created using 'Save As' from the browser.
    The person who has created the file is a non-technical .. and won't know much about this all stuff... encoding etc.

Maybe you are looking for

  • Payment terms in vendor  Master

    Hi, In XK01- create vendor master, There are two payment terms--> payment transaction field and other in purchasing organisation data. Is there a configuration which will default the payment terms in purchasing org screen based on the inputs in the c

  • Why will iphone not show up in itunes

    My iphone doesn't show up in tunes. It shows up on the computer but wont show up in itunes. Does anybody know how to fix this.

  • Creating Service Entry Sheet without using Service Master/Service lines

    We are invoking the BAPI_EntrySheet_Create to create the service entry sheet. We are currently facing this issue... 1) For assigned PO's, we are getting the PO item and Account assignment information from BAPI_PO_GetDetail. We are using these values

  • PDF documents on the web appear in the address bar, but the documents don't display.

    In the last week, every time I have clicked on a PDF document in Firefox, a new tab properly opens with the correct address in the box (ending with .pdf), but the documents don't appear.....? It seems to be a problem with the Adobe reader plug-in, bu

  • Android: How to upload a file to OneDrive?

    Iam trying to upload a file using the OneDrive Saver sample app. Instead of creating a text file, I would like to select a file from the gallery and then upload it to OneDrive. I have edited the sample app but the file cannot be uploaded. I don't hav