Ow to convert an Unicode code to the corresponding character
hi,I'm encountering a problem.I have an Unicode code,for example,'0041' which is corresponding to the character 'A'.I can get this character by using escape character "\u0041".However ,if I assemble it , i.e. "\\u"+"0041",I can only get "\u0041".How can i resolve this question?thanks in advance.in addition which file in java source code realizes the function of escape character
Edited by: wl1205626 on Oct 17, 2007 1:51 AM
My dear friend this code can change "u0061u0062u0063u0061" in "\u0061\u0062\u0063\u0061" unicode formate and second code can change a uniCode data in char
import java.util.*;
class conv
public static void main(String[] args)
{String s1=new String("u0061u0062u0063u0061");
StringBuffer sb=new StringBuffer(s1);
int l=sb.length();
int z=0;
for(int i=0;i<l;i++)
char k=sb.charAt(i);
if(k=='u')
z=z+1;
sb.setCharAt(i,'L');
sb.insert(i+1,"L");
sb.setCharAt(i,'
int a=sb.length();
for(int i=0;i<a;i++)
char k=sb.charAt(i);
if(k=='L')
sb.setCharAt(i,'u');
String val=new String(sb);
System.out.println(val);
String s4= new String(val);
System.out.println(s4);
Second Programe for change Unicode to Char Conversion
public class Test
public int ss1()
int a=10,b=9;
int c=a*b;
return c;
public String loadConvert(String theString) {
char aChar;
int len = theString.length();
StringBuffer outBuffer = new StringBuffer(len);
for (int x=0; x<len; ) {
aChar = theString.charAt(x++);
if (aChar == '\\') {
aChar = theString.charAt(x++);
if (aChar == 'u') {
// Read the xxxx
int value=0;
for (int i=0; i<4; i++) {
aChar = theString.charAt(x++);
switch (aChar) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
value = (value << 4) + aChar - '0';
break;
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
value = (value << 4) + 10 + aChar - 'a';
break;
case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F':
value = (value << 4) + 10 + aChar - 'A';
break;
default:
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.");
outBuffer.append((char)value);
} else {
if (aChar == 't') aChar = '\t';
else if (aChar == 'r') aChar = '\r';
else if (aChar == 'n') aChar = '\n';
else if (aChar == 'f') aChar = '\f';
outBuffer.append(aChar);
} else
outBuffer.append(aChar);
return outBuffer.toString();
}
Similar Messages
-
What is cause of processing delay. Fraction of a second delay between hitting a key and seeing result on screen. Another example is when scrolling, the scroll is delayed for a fraction of a second.
This is only in Word? Sounds like Microsoft's software has a bug. Have you checked for available updates in Microsoft AutoUpdate?
-
How do I get Unicode chars beyond the ASCII range to display ?
Hello all.
I have just recently started to learn Java.
I want to display the data in a array using Unicode characters, but when I use the unicode code from the code sheet I merely get a ?.
I looked about the net and understand that Java doesnt support none ASCII characters (by default?) , I think its possible to import various codes but not sure about that.
Anyways...
My question is: How do I get the Unicode character 2254 Box Drawing Element to display (also other non standard ASCII ) ? Print("\u2254") results in a ?.
If you are wondering why:
I want to store a map for a game into a data array with the entities represented as normal letters and characters, this map will be generated by the program randomly but I want to see the output of the map to test if its obeying the rules I set out for the map generation.
I figured just read the array and print out the result , but to make it more legible in debugging convert the text characters to box drawing characters.Both methods you mentioned just generate a question mark instead of the box drawing element I want.
I can get all the normal, ie letters and numbers and the common characters... but beyond that and all I get is a '?' in its place.
Initially I just wanted it to print the character in the legend.
The code below just prints a few lines of text , the legend to decipher the level display, and calls a class to create a level ..then the last call is to call a debug class to display the level that was created.
* Prelim Code for the Random Dungeon Generator *
* used in Dungeon Runner *
* Created : 03/07/2009 *
public class DungeonGenerator {
public static void main (String[] args) {
System.out.println(
"Prelimary code for the Random Dungeon Generator for Dungeon Runner Game\n\n"
); // Just a text heading reminder for me
System.out.println(
"Test 1 - debug screen - 03 July 2009\n\n"
System.out.println("Legend: \u2254 = Top Left Corner \t 2 = Top Right Corner");
System.out.println(" 3 = Bot Left Corner \t 4 = Bot Right Corner");
System.out.println(" L = Left Wall \t\t R = Right Wall");
System.out.println(" T = Top Wall \t\t B = Bottom Wall");
System.out.println(" D = Doorway \t\t + = Play Space");
System.out.println(" E = Exit Entity \t S = Start Entity");
System.out.println(" . = None Play Space");
System.out.println("\n----------------------------------------------------\n");
// Call the LevelGen
/** This is just a temperary call method
I am will use another array and a
loop to call the LevelGen the
number of levels I decide the
game will have
LevelGen levelone = new LevelGen(); // Calls the LevelGen to create a Level
levelone.displayLevel(); // Display the level that was generated
// for debugging only
} // End Main method
} // End DungeonGenerator class -
What encoding is the wide character,UCS2, UTF-8, other?
(please view using simplified chinese encode )
environment sets:
LC_CTYPE=zh_CN.GB18030 LC_ALL=zh_CN.GB18030
my C program code:
wchar_t *pwc = L"��";
main()
printf("\n [%x]", *pwc);
run it, the printing result: [2bc7]
I expect to get the UCS2 code value 0x6c49 of ����"(the character in GB2312 standar) ,but the result is wrong.
my questions:
1. What is the wide character that had be got by adding 'L' before locale character ������. Is it UCS2 , UTF-8, other code?
2. How to getting the UCS2 code of the locale character '��' by adding "L"?I see your issue. I tried to reproduce this issue using sqlplus.
Setup NLS_LANG as you mentioned using WE8ISO8859P1 and connect to a UTF8 db.
[oracle@server ~]$ locale -a | grep en_US
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
[oracle@server ~]$ export LC_ALL=en_US.iso88591
[oracle@server ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.iso88591"
LC_NUMERIC="en_US.iso88591"
LC_TIME="en_US.iso88591"
LC_MEASUREMENT="en_US.iso88591"
LC_IDENTIFICATION="en_US.iso88591"
LC_ALL=en_US.iso88591
[oracle@server ~]$ echo $NLS_LANG
AMERICAN_AMERICA.WE8ISO8859P1
SQL> select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
AL32UTF8
SQL> select nchr(223) from dual;
NCHR
ß
SQL> select chr(223) from dual;
ERROR:
ORA-29275: partial multibyte character
SQL> SELECT CHR (223 USING NCHAR_CS) from dual;
C
ß
SQL> select CONVERT('ß', 'WE8ISO8859P1','UTF8') FROM DUAL;
CO
SQL> select CONVERT(CHR(223 USING NCHAR_CS), 'WE8ISO8859P1','UTF8') FROM DUAL;
select CONVERT(CHR (223 USING NCHAR_CS), 'WE8ISO8859P1','UTF8') FROM DUAL
ERROR at line 1:
ORA-12703: this character set conversion is not supportedI found that beta is in WE8ISO8859P1 character set
here[url http://docs.oracle.com/cd/E11882_01/server.112/e10729/ch2charset.htm#NLSPG164]What Characters Does a Character Set Support?
But I don't really understand whats the problem in the conversion. -
Hello, we currently have a 9.2 database that is set up as Western European. We are upgrading to 10g and we now need to support unicode. I was planning on changing all the CHAR and VARCHAR2 data types to NCHAR and NVARCHAR2. I was also going to change the character set to AL32UTF8 and the national character set to UTF8. Is this what is necessary to support unicode characters?
Can I upgrade a 9i database to 10g and convert everything? Would I be able to export the 9i database and import it in to the 10g UTF8 database? At that point all the data would be normal characters.
If any one has had experience doing this I would appreciate whatever you could provide.
Thank you kindly,
David- Kieth's recollection about changing the character set of a database is correct. Basically, in order for the ALTER DATABASE CHARACTER SET command to work, the destination character set has to be a strict binary superset of the source character set. That means that every character in the source character set has to have exactly the same binary representation in the destination character set. For any of the Western European character sets, characters 0-127 will generally match US7ASCII and have the same binary representation in UTF8, but characters 128-255 will have a different binary representation in UTF8. That means that direct upgrades are not possible.
- I would generally avoid using NCHAR/ NVARCHAR2 data types except as a last resort. Those data types are more appropriate where you have a need to store data in multiple different character sets in the same database (i.e. you want to use Windows-1252 for your base tables and you want to support Unicode in a handful of new tables, you want to reduce storage requirements by storing some Asian data in the UTF16 character set rather than in UTF8). If you want the entire database to be able to store Unicode data, using national character set data types is generally the wrong approach architecturally.
Practically, it's also a problem to move everything to NCHAR/ NVARCHAR2 because you'd have to re-create all your tables (or add and drop a lot of new columns) which is going to be at least as slow as the Data Pump export & import approach. It would also entail lots of code changes, and some APIs don't support NCHAR/ NVARCHAR2 data types, so you might have to make substantial architectural changes to the apps.
- In addition to being aware of the character/ byte semantics Keith mentioned (some_column varchar2(3) by default allocates 3 bytes not 3 characters of storage space which becomes important when you have a variable length character set like UTF8 where 1 character can be up to 3 bytes long), be aware that there is an initialization parameter NLS_LENGTH_SEMANTICS that can be set to CHAR to change the default for new DDL to specifying lengths in characters rather than bytes.
- Finally, you cannot (in recent Oracle versions) use UTF8 as the national character set. You pretty much need to use UTF16. And it wouldn't be useful to have the national character set and the database character set be the same.
Justin -
Convert 2byte Unicode inside of XI 2.0 into 1byte ascii
Hi,
does anyone know if there is the possibility inside of XI 2.0 to convert 2byte Unicode into 1byte ascii?
We are sending IDOCs from an UC R/3 system down to XI 2.0 and from
there to a MS-SQL db through JDBC Adapters. Unfortunately the MS-SQL db cannot handle UC.
Thanks and regards
Nesimi
+49.4321.871.428Duhh....
Here's the code I ended up using, in case others are having the same question.
byte[] b = Encoding.ASCII.GetBytes("ABC");
blob.Write(b,0,b.Length); -
Hello,
I am working on one project and there is need to extract Sharepoint list data and import them to SQL Server table. I have few lookup columns in the list.
Steps in my Data Flow :
Sharepoint List Source
Derived Column
its formula : SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1))
Data Conversion
OLE DB Destination
But I am getting the error of not converting between unicode and non-unicode string data types.
I am not sure what I am missing here.
In Data Conversion, what should be the Data Type for the Look up column?
Please suggest here.
Thank you,
Mittal.You have a data conversion transformation. Now, in the destination are you assigning the results of the derived column transformation or the data conversion transformation. To avoid this error you need use the data conversion output.
You can eliminate the need for the data conversion with the following in the derived column (creating a new column):
(DT_STR,100,1252)(SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1)))
The 100 is the length and 1252 is the code page (I almost always use 1252) for interpreting the string.
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com -
How to convert 864 Transaction code into XML in EDI to File Scenario
Hello Friends,
Can any body help me out in using 864 Transaction Code (Tex Message) in EDI to Flat File Conversion?? I mean i am using just 2 Fields i.e Name and Address.I didnt understand the Format given<u><i>..Here is the format for Name
N1 Name </i></u> Pos: 040 Max: 1
Heading - Optional
Loop: N1 Elements: 4
To identify a party by type of organization, name, and code
Element Summary:
<u><i>Ref Id Element Name Req Type Min/Max Usage</i></u>
N101 98 Entity Identifier Code M ID 2/3 Must use
Description: Code identifying an organizational entity, a physical
location, property or an individual
All valid standard codes are used.
N102 93 Name C AN 1/60 Used
Description: Free-form name
N103 66 Identification Code Qualifier C ID 1/2 Used
Description: Code designating the system/method of code structure used
for Identification Code (67)
All valid standard codes are used.
N104 67 Identification Code C AN 2/80 Used
Description: Code identifying a party or other code
Syntax:
1. N102 R0203 -- At least one of N102 or N103 is required.
2. N103 P0304 -- If either N103 or N104 are present, then the others are required.
Comments:
1. This segment, used alone, provides the most efficient method of providing organizational identification. To obtain this efficiency the "ID Code" (N104)
must provide a key to the table maintained by the transaction processing party.
2. N105 and N106 further define the type of entity in N101.
[<u>b]
Here is the format for Address</b></u>
N3 Address Information Pos: 060 Max: 2
Heading - Optional
Loop: N1 Elements: 2
To specify the location of the named party
Element Summary:
<b><u><i>Ref Id Element Name Req Type Min/Max Usage</i></u></b>
N301 166 Address Information M AN 1/55 Must use
Description: Address information
N302 166 Address Information
Description: Address information O AN 1/55 Used
So Help me hoe to convert this into XML...try this
For EDI U need SEEBURGER Adapter or Conversion agent by itemfield.
Using Conversion agent convert EDI Into XSD and Import using External definition.
Have look
EDI Conversion
Re: Seeburger Splitter adapter!!
Thanks -
Convert Below Java code equivalent to c# windows store app.
Hi
please help me " To convert Below Java code equivalent to c# windows store app."
private String SecretKey = "enctsbqrm6hxyjfa";
public byte[] encrypt(String text) throws Exception
if(text == null || text.length() == 0)
throw new Exception("Empty string");
// convert key to bytes
byte[] keyBytes = SecretKey.getBytes("UTF-8");
// Use the first 16 bytes (or even less if key is shorter)
byte[] keyBytes16 = new byte[16];
System.arraycopy(keyBytes, 0, keyBytes16, 0, Math.min(keyBytes.length, 16));
// convert plain text to bytes
byte[] plainBytes = text.getBytes("UTF-8");
// setup cipher
SecretKeySpec skeySpec = new SecretKeySpec(keyBytes16, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
//byte[] iv = new byte[16]; // initialization vector with all 0
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
// encrypt
byte[] encrypted = cipher.doFinal(plainBytes);
return encrypted;
Thanks
NitinHello Nitin,
Your current requirement is beyond the scope of our support for this fourm which is used to Discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.
If you want to know how to encrypt/decrypt in windows store app, I suggest that you could post a it to:
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/home?forum=winappswithcsharp
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Convert simple animation code from as2 to as3
Hi everyone,
I have a simple animation that is controlled by the y movement of the mouse. The code for the animation is put in frame 1 and is as follows:
var animationDirection:Boolean = false;
var prevMousePosition:Boolean = false;
var mouseListener = new Object();
mouseListener.onMouseMove = function () {
var curMousePosition = _ymouse;
if(curMousePosition > prevMousePosition) {
animationDirection = false;
}else if(curMousePosition < prevMousePosition) {
animationDirection = true;
prevMousePosition = curMousePosition;
Mouse.addListener(mouseListener);
function onEnterFrame() {
if(animationDirection && _currentframe < _totalframes) {
nextFrame();
}else if(!animationDirection && _currentframe > 1) {
prevFrame();
Is it possible to use this code in as3 or do I need to convert it? I am grateful for any help. Best wishesYes, you need to convert the code. Here is what looks like a similar logic in AS3:
import flash.events.Event;
import flash.events.MouseEvent;
var animationDirection:Boolean = false;
var prevMousePosition:Boolean = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
function onMouseMove(e:MouseEvent):void {
var curMousePosition = mouseX;
if (curMousePosition > prevMousePosition)
animationDirection = false;
else if (curMousePosition < prevMousePosition)
animationDirection = true;
prevMousePosition = curMousePosition;
function onEnterFrame(e:Event):void
if (animationDirection && _currentframe < _totalframes)
nextFrame();
else if (!animationDirection && _currentframe > 1)
prevFrame(); -
How to get the ANSI codes in the program
Hi,
In my program, I have to get the ANSI codes 30 and 31 in the program. After getting those codes, I have to concatenate with some other text and display in the report.
Can someone tell me how to get these ANSI codes in the program..?
Is there any function module to get the ANSI codes in the program. or Is there any other way to get the ANSI codes in the program.
Please help me. It is quite urgent.
Thanks in advance,
Best Regards,
Pradeep.hi check this ....
How can I get Ascii value of any letter
How can I get Ascii value of any letter. Is there any function?
This is how you do it :
report demtest.
data : c.
field-symbols : <n> type x.
data : rn type i.
c = 'A'.
assign c to <n> casting.
move <n> to rn.
write rn.
This will convert 'A' to 65.
Tom Demuyt
How to convert ascii value to character.
If I give input as 65 (ascill value) I want display 'A'.
Below logic is for convert from character to ascii value , now I want to know how to convert ascii value to character.
Naveen
report demtest.
*going from A to 65
data : c value 'A'.
field-symbols : <n> type x.
data : rn type i.
assign c to <n> casting.
move <n> to rn.
write rn.
*going from 66 to B
data : i type i value 66.
data : x type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.
regards,
venkat. -
How to convert pl/sql code into java/j2ee
Hi,
We have a PL/SQL Oracle App server application that we will support if we can convert in j2ee/java. But when i did take a look at the code, these pl/sql contains all HTML and java code inside the stored procedures.
And iam looking to explore some tools and mechanisms that can convert these pl/sql in a JAVA application so that i can deploy this new app into my BEA81 environment.
Does any body has any idea:
a) How to convert from pl/sql > java ?
b) Any plugins or tools of BEA that can run these pl/sql (the way thay are currently...i.e w/o converting) in BEA 81 container ?
thanks, sangitathese pl/sql contains all HTML and java code insideJava or JavaScript. They are not the same. I wouldn't expect to see Java inside html, whereas JavaScript would be intermixed. On the other hand you might have a java stored proc (Oracle 9/10) which is generating HTML.
>
Does any body has any idea:Refactor.
I doubt it just has html and JavaScript/Java. So what you have is a mess that mixes several things that should have been seperate in the first place. -
Cannot convert between unicode and non-unicode string datatypes
My source is having 3 fields :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
My destination is :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
But still I am getting this error :
Column ItemCode cannot convert between unicode and non-unicode string datatypes.
As I am new to SSIS , please show me step by step.
Thanks In Advance.My source is having 3 fields :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
My destination is :
ItemCode nvarchar(50)
DivisionCode nvarchar(50)
Salesplan (float)
But still I am getting this error :
Column ItemCode cannot convert between unicode and non-unicode string datatypes.
As I am new to SSIS , please show me step by step.
Thanks In Advance.
HI Subu ,
there is some information gap , what is your source ? are there any transformation in between ?
If its SQL server source and destination and the datatype is as you have mentioned I dont think you should be getting such errors ... to be sure check advance properties of your source and check metada of your source columns
just check simple oledb source as
SELECT TOP 1 ItemCode = cast('111' as nvarchar(50)),DivisionCode = cast('222' AS nvarchar(50)), Salesplan = cast(3.3 As float) FROM sys.sysobjects
and destination as you mentioned ... it should work ...
somewher in your package the source columns metadata is not right .. and you need to convert it or fix the source.
Hope that helps
-- Kunal
Hope that helps ... Kunal -
How to write processing code for the Inbound IDOC to the R/3 ??
i m having a file -> XI-->R/3 scenario,
IDOC is being sent from XI to R/3,
can u guide to me to write a processing code for the Inbound IDOC to the R/3,
since i m new to ABAP and ALE technology, can we provide me any blog for doing that.......or guide me....Hi Sudeep
Simple File to Idoc scenarion blog
/people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping - Any flat file to any Idoc
Also see the blog
<a href="/people/ravikumar.allampallam/blog/2005/02/23/configuration-steps-required-for-posting-idocsxi Steps for Posting IDOC's</a> by Ravikumar.
Configuration of IDOC adapter
http://help.sap.com/saphelp_nw04/helpdata/en/96/791c42375d5033e10000000a155106/frameset.htm
Regards
Santhosh
*Reward points if useful* -
How to protect JSP source code on the Server Side ?
I am new on JSP. I Already know about various Web and Desktop technologies but is the first time on JSP. I know ASP for example.
Well, about .NET platform, it protects my source code on the server, the source code is compiled and on the server, only the compiled file are installed, my source code stay with me...
About JSP, how it works about ? Is possible to hide my source code too ? What the technique to hide the codes ? I need to prevent access to my source codes...
Robertoroberto.novakosky wrote:
About .exe files, do you know if a java class is more easy or dificult to do reverse engineering ?Depends on who your enemy is. If it's for example a hacker with a lot of C knowledge but zero of Java knowledge, reverse engineering .exe would be easier than .class. If one was interested, one would always take time to learn how to decompile the one or other. Making files secure is a waste of time. It's always "hackable".
If there was a proof of concept, no one major software vendor would have had so much problems with piracy and cracks/keygens. Think about it once again. It's simply impossible. Just have a clear EULA and actually make work of it whenever you discovers if someone breaks your EULA.
I was thinking about, the .JSP can be converted to servlet .java, and converted to .class, this way hide the source code.Once again, one could still decompile it (or reverse engineer, so you call).
Maybe you are looking for
-
Error while Invoking Web Service: Fusion Payables( CreateInvoiceInterface)
HI, We are testing the webservice from fusion/em site but encountered with an error 'oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : MOAC Priv Name cannot be null; Initialize MOAC" Details:- Url: Fu
-
I'm new to coding and Dreamweaver CS6 and have been working with the fluid grid layout. When I view the template page in Safari Preview, my website looks like the image below. After saving and putting the files the page looks completely different w
-
Movie hasnt downloaded for the past 3 days
-
30" cinema display + MacBook Pro Question
Before purchasing a display, I was under the impression that to connect the 30" cinema HD to my MacBook Pro, I also required a Mini DisplayPort to Dual-Link DVI Adapter. However, I've since been able to connect it straight to my MacBook Pro with only
-
I'm not able to download Oracle V9.2.0.1(HP-Unix) as I'm getting the following error message. "The gateway could not receive a timely response from the Web site you are trying to access. This might indicate that the network is congested, or that the