Problem to put a special character in a string
I read a file that contains some special characters.
One of them has a hexadecimal value '8D'.
When i put this in a string or a char, it give me '?'.
If i read my file int by int, this char value is 65533
How can I do to display this character as it must be? How can i transform it to put it in a string?
8D is "reverse linefeed" in unicode: http://www.unicode.org/charts/PDF/U0080.pdf
Obviously it's something else in your system's character encoding. What do you think you should get from 8D?
Similar Messages
-
Replacing a special character in a string with another string
Hi
I need to replace a special character in a string with another string.
Say there is a string - "abc's def's are alphabets"
and i need to replace all the ' (apostrophe) with &apos& ..which should look like as below
"abc&apos&s def&apos&s are alphabets" .
Kindly let me know how this requirement can be met.
Regards
SukumariREPLACE
Syntax Forms
Pattern-based replacement
1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
pattern
IN [section_of] dobj WITH new
[IN {BYTE|CHARACTER} MODE]
[{RESPECTING|IGNORING} CASE]
[REPLACEMENT COUNT rcnt]
{ {[REPLACEMENT OFFSET roff]
[REPLACEMENT LENGTH rlen]}
| [RESULTS result_tab|result_wa] }.
Position-based replacement
2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
[IN {BYTE|CHARACTER} MODE].
Effect
This statement replaces characters or bytes of the variable dobj by characters or bytes of the data object new. Here, position-based and pattern-based replacement are possible.
When the replacement is executed, an interim result without a length limit is implicitly generated and the interim result is transferred to the data object dobj. If the length of the interim result is longer than the length of dobj, the data is cut off on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted. If data is cut off to the right when the interim result is assigned, sy-subrc is set to 2.
In the case of character string processing, the closing spaces are taken into account for data objects dobj of fixed length; they are not taken into account in the case of new.
System fields
sy-subrc Meaning
0 The specified section or subsequence was replaced by the content of new and the result is available in full in dobj.
2 The specified section or subsequence was replaced in dobj by the contents of new and the result of the replacement was cut off to the right.
4 The subsequence in sub_string was not found in dobj in the pattern-based search.
8 The data objects sub_string and new contain double-byte characters that cannot be interpreted.
Note
These forms of the statement REPLACE replace the following obsolete form:
REPLACE sub_string WITH
Syntax
REPLACE sub_string WITH new INTO dobj
[IN {BYTE|CHARACTER} MODE]
[LENGTH len].
Extras:
1. ... IN {BYTE|CHARACTER} MODE
2. ... LENGTH len
Effect
This statement searches through a byte string or character string dobj for the subsequence specified in sub_string and replaces the first byte or character string in dobj that matches sub_string with the contents of the data object new.
The memory areas of sub_string and new must not overlap, otherwise the result is undefined. If sub_string is an empty string, the point before the first character or byte of the search area is found and the content of new is inserted before the first character.
During character string processing, the closing blank is considered for data objects dobj, sub_string and new of type c, d, n or t.
System Fields
sy-subrc Meaning
0 The subsequence in sub_string was replaced in the target field dobj with the content of new.
4 The subsequence in sub_string could not be replaced in the target field dobj with the contents of new.
Note
This variant of the statement REPLACE will be replaced, beginning with Release 6.10, with a new variant.
Addition 1
... IN {BYTE|CHARACTER} MODE
Effect
The optional addition IN {BYTE|CHARACTER} MODE determines whether byte or character string processing will be executed. If the addition is not specified, character string processing is executed. Depending on the processing type, the data objects sub_string, new, and dobj must be byte or character type.
Addition 2
... LENGTH len
Effect
If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len bytes or characters of sub_string are used for the search. For len, a data object of the type i is expected.
If the length of the interim result is longer than the length of dobj, data objects of fixed length will be cut off to the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or with hexadecimal 0. Data objects of variable length are adapted.
Example
After the replacements, text1 contains the complete content "I should know that you know", while text2 has the cut-off content "I should know that".
DATA: text1 TYPE string VALUE 'I know you know',
text2(18) TYPE c LENGTH 18 VALUE 'I know you know',
sub_string TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.
REPLACE sub_string WITH new INTO text1.
REPLACE sub_string WITH new INTO text2. -
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,
RajivFine..... 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. -
Detect special character from a String
Hello guys,
Some of the files in unix box contain special characters . I need to strip these special character in the filename to underscore. however, I do not want to strip off special character like _ - ^ . @
Pattern escaper = Pattern.compile("([^a-zA-z0-9_-^.@])");
I couldn't strip off the caret. Appreciate any advice please. Thanks in advance!
Cheers,
MarkHi Alice,
I tried your suggestion:
public static void main(String[] args) throws IOException {
rename(args[0], args[0].replaceAll("[^a-zA-Z0-9\\\\/:@._^-]","_"));
public static void rename(String from, String to) throws IOException{
// File (or directory) with old name
File file1 = new File(from);
// File (or directory) with new name
File file2 = new File(to);
// Rename file (or directory)
boolean success = file1.renameTo(file2);
if (!success) { // File was not successfully renamed
System.out.println("failed to rename : " + file1);
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1~2.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1^2.txt
failed to rename : C:\Apps\mud\12.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\[email protected]
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1@2$-_3mn.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1@2$-_3mn.txt
failed to rename : C:\Apps\mud\1@2$-_3mn.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1@2$-_3m'n.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1@2$-_3m'^n.txt
failed to rename : C:\Apps\mud\1@2$-_3m'n.txt
C:\workspace\TestOnly\bin>java -cp . com.test.TestClass C:\Apps\mud\1@2$-_3m'^n.txtbut however, whenever I put in a caret in the filename, it always failed to rename. Appreciate your further advice please. thanks in advance!
Cheers,
Mark -
Special character ' in the string variable
Hi,
I need to insert in the string veriable the special character '. How should I do it ?
variable = '''.
It does not work ...
BR
Wojcieh1)Declare a variable and assign the special character to that variable.
2)Then use the CONCATENATE option to get the value in the string variable.
Just copy and execute this code.
REPORT zztest.
<b>DATA : temp(1) VALUE ''''.</b> Decalare your special character
DATA : variable TYPE string.
START-OF-SELECTION.
BREAK-POINT.
variable = 'SDNSAP'.
CONCATENATE temp variable temp INTO variable.
WRITE : / variable.
<b>The output is</b>
'SDNSAP'
Regards,
AS. -
Putting a null character in a String?
Hi,
I need to send a null character through a nio channel. Specifically, it needs to be decoded from a String into a byte array. Can I append a null character to a String so that getBytes() method will return it? Thanks,
rankoThanks, I tried that but it doesn't work. I also
tried appending '\0' and an uninitialized character
which should by default have a value of a null
character. I tried creating a String out of a char
array that has one element containing a null character
but that did not work either. I guess that since null
characters end the String, you cannot actually add
them to the body of the String. Or is there a way?FYI, strings aren't null-terminated in Java. -
Counting a Special Character from a String
Hello,
I have a String let say 'ABC-X', 'ABC-X-Y' ....
so how can we find the count/No. of Hypen('-') .. in a string....I have a String let say 'ABC-X', 'ABC-X-Y' ....
so how can we find the count/No. of Hypen('-') .. in a string....
SQL> var str varchar2(20);
SQL> exec :str := 'ABC-X-Y';
PL/SQL procedure successfully completed.
SQL> select length(:str) - nvl(length(replace(:str,'-')),0) from dual;
LENGTH(:STR)-NVL(LENGTH(REPLACE(:STR,'-')),0)
2
SQL> -
How to detect any special character ina string?
Hi!
I'm having a problem with a string. Basically the string is an output of some function and that may contains some special character which is not shown in the string - for example - chr(10)/chr(13) etc.
Is there any method or procedure that can detect all the special character inside that string and remove them all other than all the characters and digitis which is in form of character? I'm using oracle 9i.
Thanks in advance for your reply.
Regards.
Satyaki De.I've tried your solution - but i don't think it is working --
satyaki>ed
Wrote file afiedt.buf
1 create or replace function extract_printable(vc varchar2)
2 return varchar2
3 is
4 c_non_printable varchar2(33)
5 := chr(00)||chr(01)||chr(02)||chr(03)||chr(04)||chr(05)||chr(06)||chr(07)||chr(08)||chr(09)
6 || chr(10)||chr(11)||chr(12)||chr(13)||chr(14)||chr(15)||chr(16)||chr(17)||chr(18)||chr(19)
7 || chr(20)||chr(21)||chr(22)||chr(23)||chr(24)||chr(25)||chr(26)||chr(27)||chr(28)||chr(29)
8 || chr(30)||chr(31)||chr(127);
9 begin
10 return(translate(vc,'a'||c_non_printable,'a'));
11* end;
satyaki>/
Function created.
satyaki>
satyaki>select length(extract_printable('this is ')) src
2 from dual;
SRC
15
satyaki>But, thanks for your reply.
Regards.
Satyaki De. -
Hi All,i am transferring XML file to SAP ,so while doing this i am facing some problem while handling some special character 'micro'. Is there any replacment for micro in SAP?......please tell me..
Hi Amruta,
you can encode the string like this.
encoded_string = cl_http_utility=>escape_html( source_string ).
Cheers
Graham -
Display special character on web page
Hello,
Is it possible to display the special character < or > in a bsp page ?
I try to do it but it seams to be interpreted as HTML and nothing is printed.
In material description in purchase requisition we have < material desc > and I would like to show this in a tableview.
For the moment I delete the special character in a string variable but it does'nt correspond to my need.
Thanks for your help
Véronique.Hello,
You could try something with special characters :
e.g. this code
« material »
produces this output
« material »
Best regards,
Dirk. -
Replace a character in the string using JavaScript
Hello,
I would like to ask for help. I have a field in the xml file, which contains a string, that is bound to a text box on the form.
What would be the syntax to replace a special character in the string with the carriage return?
Thank you.Huh?
I didn't post my script...
It sure is no clean programming since I just took Steve's solutions and delted the ligns I didn't want (the app allert)
Though in the end I've taken the boolean out, or better replaced it with the replacement function, it repeats the replacement no matter how much "ü"'s are in there. (I needed the boolean though, since as long as it was true, the if should be executed.)
Somehow it worked... not 100% sure why, but it worked.
if (findChar(this.rawValue)) {
function findChar(str)
{ for (var i=0; i < str.length; i++)
if (str.charAt(i) == "ü")
this.rawValue = this.rawValue.replace(/ü/,"ue") -
Xml publisher reprot - special character problem
I invoice report through xml publisher. I have '&' special character in vendor list. I am getting below error
A semi colon character was expected. Error processing resource.
Below is the code
CREATE OR REPLACE PACKAGE BODY XML_RPT AS
FUNCTION XML_TAG (p_tag IN VARCHAR2, p_data IN VARCHAR2) RETURN VARCHAR2 IS
l_ret_str VARCHAR2(5000);
BEGIN
l_ret_str := '<'||p_tag||'>'||p_data||'</'||p_tag||'>';
RETURN l_ret_str;
END XML_TAG;
PROCEDURE VENDOR(errbuf OUT VARCHAR2,
retcode OUT NUMBER) IS
CURSOR inv_Cur IS
select pv.vendor_name
from po_vendors pv;
xmldata varchar2(1000);
l_sqlstr varchar2(1000);
l_seqnum varchar2(3);
l_vendor_name varchar2(100);
BEGIN
xmldata := '<?xml version="1.0" encoding="UTF-8"?>';
xmldata :=xmldata|| '<VENDOR>';
xmldata := xmldata||' <LIST_VENDOR>';
fnd_file.put_line(fnd_file.output,xmldata);
FOR rpt_rec IN inv_Cur LOOP
xmldata := '<VENDOR_REC>';
l_vendor_name := replace(rpt_rec.VENDOR_NAME,'&','&');
xmldata := xmldata || XXMCG_XML_TAG('VENDOR_NAME',L_VENDOR_NAME);
xmldata :=xmldata|| '</VENDOR_REC>';
fnd_file.put_line(fnd_file.output,xmldata);
END LOOP;
xmldata := '</LIST_VENDOR>';
xmldata := xmldata||'</VENDOR>';
fnd_file.put_line(fnd_file.output,xmldata);
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,substr(SQLERRM,1,500));
END VENDOR;
END XML_RPT;can any one advice.Duplicate post ? xml publisher report problem
Srini -
Request.getParameter(): special character handling problem
Hello, there:
This should be an easy question for the gurus in here.
I use a string attached to the url as the parameter string, which includes spaces. the system automatically converts them to %20, but when I receive them in my servlet using request.getParameter, a special character, Â appears; I couldn't proceed with it.
I suppose this is a common problem but seems that I didn't find topics about it on this forum.
So anyone can help? Any encoder/decoder APIs to handle it?
Thanks a lot,
Swayhi,
escape can solve ur problem
use js function to submit form like
function subForm()
var any_spcl_value ="kdfhjdf$%@#$% 2FGSFG @%@#%@# V";
mainForm.action = "index.jsp?value="+ escape(any_spcl_value);
mainForm.submit();
and use request.getParameter("value");
u ll get kdfhjdf$%@#$% 2FGSFG @%@#%@# V as it is.
AE -
Problem with special Character & in Proxy
Hi,
We have a File --> XI --> R/3 Scenario. In this scenario, from XI we are passing the data to R/3 by calling the Proxy. When the data in the file has special character like & (for example <Companyname>Dave&Busters</Companyname>), it is failing in R/3. But if I replace "&" with "&" in the file it works fine. Is there any solution to this problem without writting custom code in XI to replace & with &.
Thanks
Sudheer>But if I replace "&" with "&" in
> the file it works fine. Is there any solution to this
> problem without writting custom code in XI to replace
> & with &.
No. If the sender of the message provides an XML format with an unescaped &, then the XML is not valid and therefore cannot be processed.
All adapters (IDOC, RFC, File with content conversion) perform the escaping and deescaping.
Regards
Stefan -
ALV Excel Download problem ( Special Character)
Hi,
I am unable to download completely in XLS format from ALV grid. When i tried in couple of ways there is a special character( " ) in one of the filed. Due to the same Excel download has some problem. I tested by removing those and it worked fine,
Please suggest me to solve the issue.
Thanks,
Bhanu Gattu,Data strings with special characters can not be downloaded into XLS format from ALV grid. In my case, I replaced the special character " with space and I could download the data into excel.
Maybe you are looking for
-
My son had place a passcode and don't remember it and he try so many times to unlocked the phone but since he did it so many times and it was the wrong passcode the phone now is disabled, How can I get it to work again?
-
About stateful active/standby failover
Hello guys. I have two ASA's, same model and hardware. Asa have configured stateful active/standby failover by someone, few years ago. It was working normally until recently and no one have changed this configuration. Then Secondary unit is failed. P
-
ITunes 12: Changing my genres, fixes don't stick
Just downgraded to iTunes 12 since Apple's answer to the MS Paper Clip, the little dialog window that won't die, finally got the best of me. What a mistake. Please don't do it, peeps. My main annoyance is that the genres of my music keep changing. I
-
Selecting same column twice makes query slow
Hello, Has anybody any idea why following statement is slow when selecting the DATA_TYPE column twice? SELECT S.OWNER, S.SYNONYM_NAME, UCOL.COLUMN_NAME, UCOL.DATA_TYPE, UCOL.DATA_TYPE, UCOL.DATA_LENGTH, COLUMN_ID FROM ALL_SYNONYMS S, ALL_TAB_COLUMNS
-
How to prevent click through?
Basically I have mulitple buttons on the stage. Every button on the stage is an instance of the same component. When one of the buttons is pushed, that component imports an MC from the library to the stage (popup window). It then creates a text box a