Manipulation with String - EBCIDIC
Hello,
I need to manipulate a String.
I have to change each letter within the String, but the conversion table I need to use is EBCIDIC.
For example :
I have to change a letter's value 64 in EBCIDIC to A3 in EBCIDIC , etc... (just like in ASCII, which I know how to do, but in EBCIDIC).
How should I do that Please ?
Thanks !!
user10271300 wrote:
Hello,
I need to manipulate a String.
I have to change each letter within the String, but the conversion table I need to use is EBCIDIC.I suspect not. Since Java String objects are always always always UNICODE encoded as UTF-16 one cannot convert a String to EBCDIC. I suspect what you actually need to do is convert the String content to bytes using EBCDIC. Something like byte[] ebcdicEncoded = "some string".getBytes("Cp500") . See http://docs.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html for possible encodings.
>
For example :
I have to change a letter's value 64 in EBCIDIC to A3 in EBCIDIC , etc... (just like in ASCII, which I know how to do, but in EBCIDIC).
How should I do that Please ?
Thanks !!
Similar Messages
-
i need to do some manipulations with dates, as like the following psuedo code.
date a=feb 14 2007;
date b=jan 31 2007;
date c=a+1; //this should do c=feb 15 2007
boolean before=b<a;//this should do as before= true
boolean after=b<a;//this should do as after=falsei searched in util.date of API. But some constructors that i cud use do this are deprecated.
So any ideas..Date in general is deprecated.No, not at all. Just many of the methods are. Date
serves one role and calendar another.fusk u jverd u no nothing you pile of sh!t u got no
rite to correct me etc blah blah noob loses it :-)Good morning to you too. :-)
I never use Date. when would you prefer it over
Calendar?When I want to represent an instant in time without needing to worry about human imposed chunkification into months, days, etc. And I use SimpleDateFormat for going between human enterable/readable strings and the "raw" Date representation.
The only time I use Calendar is when I want to do day/week/month/year math on it, like "first day of the month" or "add one week" or "midnight on the day represented by this Date." -
Urgent!!!!!! Issue with String in CO
Hi All,
I am learner of OAF.
I have issue with string while converting into double.
In AM,
public String ComputeMarginPercent()
retrun form.format((55570.0*100)/184.64999999999418);
in CO..I am getting the value:
String s1 = (String)oapagecontext.getApplicationModule(oawebbean).invokeMethod("computeMarginPercent");
here getting value of s1=30,094.77
I need to convert s1 to double, while converting double its raising error.
how can I remove comman in (30,094.77) this number..?
please advise me ..Hi Pratap,
I am new to java ..
Can you please tell me in step by step..?
Thanks in advance
I tried like /..
String str= "30,094.77 ";
char[] chars = str.toCharArray();
String s = String.copyValueOf(chars);
System.out.println(s);
Still displaying value as 30,094.77 (with comma)
Edited by: user633508 on Nov 21, 2008 2:55 AM -
I am new to Java Programming.
I have a line of code that works and does what is supposed to.
faceData.getProfile("Lisa").removeFriend("Curtis");
If I assign the strings to variables such as-
String name = "Lisa";
String fName = "Curtis";
and then plug those into the same line of code, it does not work
faceData.getProfile(name).removeFriend(fName);
What could be causing the problem?
I even added some lines to print out what is stored in the variables to verify that they are what they should be, but for some reason the variables do not work while putting the strings in quotes does. Any ideas?I guarantee that something about your assertions are incorrect. Those variables are either not equal to the values you claim, or something else is going on. But it's not a problem with string variables versus string constants.
Edit: My best guess in lack of a real example from you, is that the strings in question have non-printable characters in them, such as trailing spaces or line feeds. -
Little problem with Strings.
I have an little problem with Strings, i make one comparision like this.
String nombre="Javier";
if( nombre.equalsIgnoreCase(output.getStringValue("CN_NOMBRESf",null)) )
Wich output.getStringValue("CN_NOMBRESf",null) is "Javier" too, because I display
this before and are equals.
What I do wrong?.
You are actually making your users key in things like
"\026"? Not very user-friendly, I would say. But
assuming that is the best way for you to get your
input, or if it's just you doing the input, the way to
change that 4-character string into the single
character that Java represents by '\026', you would
use a bit of code like this:char encoded =
(char)Integer.parseInt(substring(inputString, 1),
16);
DrClap has the right idea, except '\026' is octal, not hex. So change the radix from 16 to 8. Unicode is usually represented like '\u002A'. So it looks like you want:String s = "\\077";
System.out.println((char)Integer.parseInt(s.substring(1), 8));Now all you have to do is parse through the String and replace them, which I think shouldn't be too hard for you now :) -
Regex with strings that contain non-latin chars
I am having difficulty with a regex when testing for words that contain non-latin characters (specifcally Japanese, I haven't tested other scripts).
My code:
keyword = StringUtil.trim(keyword);
//if(keywords.indexOf(keyword) == -1)
regex = new RegExp("\\b"+keyword+"\\s*;","i");
if(!regex.test(keywords))
{Alert.show('"'+keywords+'" does not contain "'+keyword+'"'); keywords += keyword + "; ";}
Where keyword is
日本国
and keywords is
Chion-in; 知恩院; Lily Pond; Bridge; 納骨堂; Nōkotsu-dō; Asia; Japan; 日本国; Nihon-koku; Kansai region; 関西地方; Kansai-chihō; Kyoto Prefecture; 京都府; Kyōto-fu; Kyoto; Higashiyama-ku; 東山区; Places;
When the function is run, it will alert that keywords does not contain keyword, even though it does:
"Chion-in; 知恩院; Lily Pond; Bridge; 納骨堂; Nōkotsu-dō; Asia; Japan; 日本国; Nihon-koku; Kansai region; 関西地方; Kansai-chihō; Kyoto Prefecture; 京都府; Kyōto-fu; Kyoto; Higashiyama-ku; 東山区; Places; " does not contain "日本国"
Previously I was using indexOf, which doesn't have this problem, but I can't use that since it doesn't match the whole word.
Is this a problem with my regex, is there a modifier I need to add to enable unicode support or something?
Thanks
Daveogre11 wrote:
> I need to use refind to deal with strings containing
accented characters like
> ?itt? l?su, but it doesn't seem to find them. Also when
using it with cyrillic
> characters , it won't find individual characters, but if
I test for [\w] it'll
> work.
works fine for me using unicode data:
<cfprocessingdirective pageencoding="utf-8">
<cfscript>
t="Tá mé in ann gloine a ithe;
Nà chuireann sé isteach nó amach
orm";
s="á";
writeoutput("search:=#t#<br>for:=#s#<br>found
at:=#reFind(s,t,1,false)#");
</cfscript>
what's the encoding for your data? -
Java Switch Statement with Strings
Apparently you cant make a switch statement with strings in java. What is the most efficient way to rewrite this code to make it function similar to a swtich statement with strings?
switch (type){
case "pounds":
type = "weight";
break;
case "ounces":
type = "weight";
break;
case "grams":
type = "weight";
break;
case "fluid ounces":
type = "liquid";
break;
case "liters":
type = "liquid";
break;
case "gallons":
type = "liquid";
break;
case "cups":
type = "liquid";
break;
case "teaspoons":
type = "liquid";
break;
case "tablespoons":
type = "liquid";
break;
}I'd create a Map somewhere with entries "liquid", "weight", etc.
public class Converter {
private static Map<String, List<String>> unitMap = new HashMap<String, List<String>>();
private static String[] LIQUID_UNITS = { "pints", "gallons", "quarts", "millilitres" };
private static String[] WEIGHT_UNITS = { "pounds", "ounces", "grams" };
static {
List<String> liquidUnits = new ArrayList<String>();
for (int i = 0; i < LIQUID_UNITS.length; i++) liquidUnits.add(LIQUID_UNITS));
unitMap.put("liquid", liquidUnits);
... // other unit types here
public String findUnitType(String unit) {
for (String unitType : unitMap.keySet()) {
List<String> unitList = unitMap.get(unitType);
if (unitList.contains(unit))
return unitType;
return null;
It might not be more "efficient", but it's certainly quite readable, and supports adding new units quite easily. And it's a lot shorter than the series of if/else-ifs that you would have to do otherwise. You'll probably want to include a distinction between imperial/metric units, but maybe you don't need it.
Brian -
How we can use OR operator with string in java??
Gaurav1 wrote:
its logical OR operator;how can we use it with matcher classLike its been said already. The "logical OR" is used the same everywhere.
Why don't you post the code you're having problems with. (Only the relevant areas, please. And use code tags.) -
Use listbox to work with strings
Hello guys,
I am struggling looking for a way to work with strings using a listbox. I think the problem is quite simple, but I don´t know how to implement it using labview.
I have an array of N elements (N is different everytime I run the program), and each element is a string (actually each element is a command). I would like load this array, and then if I select an element (by double-clicking or something similar), I would like to get a translation of the command.
In fact, I only need a way of loading the array, selecting an element, and then put it into a variable that would be translated with a SubVI that I have already implemented.
Do you have any clue of doing this? I have tried with the multicolumn listbox, but I cannot connect any array of strings to it, and I am starting to have a lack of new ideas...
Many thanks for your helpMaybe this helps you:
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it. -
Revision: 3246
Author: [email protected]
Date: 2008-09-17 15:31:25 -0700 (Wed, 17 Sep 2008)
Log Message:
Fix fasttrack bug SDK-16910 - Simple List populated with strings throws RTE. This is fallout from the Group/DataGroup split. DefaultItemRenderer now uses a TextBox instead of a Group to show the list data.
QE: Any List tests that depended on the default item renderer to support anything other than text must be updated.
Bugs: SDK-16910
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-16910
http://bugs.adobe.com/jira/browse/SDK-16910
Modified Paths:
flex/sdk/trunk/frameworks/projects/flex4/src/flex/skin/DefaultItemRenderer.mxmlBTW, I do not experience the bug you had mentioned at
http://www.cs.rit.edu/~cxb0025/flex/TreeControlBugs.html
Can submit a video of my actions recorded -
Problem with String to Int conversion
Dear Friends,
Problem with String to Int conversion
I am having a column where most of the values are numeric. Only 4 values are non numeric.
I have replaces those non numeric values to numeric in order to maintain the data type.
CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END
This comes the result as down
Grade
_0_
_1_
_10_
_11_
_12_
_13_
_14_
_15_
_16_
_17_
_18_
_19_
_2_
_20_
_21_
_22_
_23_
_24_
_3_
_4_
_5_
_6_
_7_
_8_
_9_
Refresh
Now I want to convert this value to numeric and do some calculation
So I changed the formula as below
cast (CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END as INT)
Now I get the following error
View Display Error
_ Odbc driver returned an error (SQLExecDirectW)._
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
_State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1722, message: ORA-01722: invalid number at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)_
SQL Issued: SELECT cast ( CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END as Int) saw0 FROM "Human Capital - Manpower Costing" WHERE LENGTH(CASE Grade.Grade WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN 'E4' THEN '23' ELSE Grade.Grade END) > 0 ORDER BY saw_0_
Refresh
Could anybody help me
Regards
Mustafa
Edited by: Musnet on Jun 29, 2010 5:42 AM
Edited by: Musnet on Jun 29, 2010 6:48 AMDear Kart,
This give me another hint, Yes you are right. There was one row which returns neither blank nor any value.
I have done the code like following and it works fine
Thanks again for your support
Regards
Code: cast (CASE (CASE WHEN Length(Grade.Grade)=0 THEN '--' ELSE Grade.Grade END) WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' when '--' then '-1' ELSE Grade.Grade END as Int) -
Using intern() with String objects
Hi, I was wondering if anybody could explain to me more about using the method intern() with String objects.
Suppose I have a String, say testString1.
I want to make it uppercase and I would like to refer to it/use it in many places in the code.
Does using the statement
testString1.toUppercase().intern()
put the uppercase testString1 in some kind of a pool? so that everytime I call testString1.toUppercase(), a new testString1 in uppercase is not created each time? Instead it is taken from the pool? Is that how this works?
I would appreciate a response from anybody who knows about this stuff.
Thanks.No !!!... It doesn't work that way.
I would recommand you (and anyone alse) not to use String.intern() unless you have a COMPLETE understanding of how it works. -
i have proubleam with string to date conversion, i out put date fromat is 2012-04-30T23:48:55.727-07:00 . so please help me the format conversion.
i wrote the method but it not workig
My method is
-(NSDate *)dateformstr:(NSString *)str
NSString *date = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSDateFormatter *dateFormate = [[NSDateFormatter alloc] init];
[dateFormate setDateFormat:@"yyyy-MM-dd'T'HH:mm:sssZZZZ"]
// NSDate *formatterDate = [dateFormate dateFromString:str];
return formatterDate;
but i did not the value and if i try othere formate i is working but my requiremet format is 2012-04-30T23:48:55.727-07:00.
can any help it out in this senario.Sorry Butterbean, but I'm interested in the answer to your question myself.
I've spent a few hours transfering my library from one computer to another and then find out that my ratings didn't transfer. Like you, I've spent many hours rating my 2000+ songs. I'm sure you have more, nevertheless, I want to find out how to get those ratings. They still show in my iTunes on my laptop but, when I go to the iTunes folder and display the details of at song, no rating is there. If you find out how to get them to display there in the iTunes folder, it seems that would be the key.
Hope you get your answer soon. -
Hello,
First off thanks in advance to anyone who helps. I am trying to write a program that using a class string object to convert this kind of "text speech" to english. For example if the user inputs "HowAreYou?", I want the program to output "How are you?" I am having too much trouble with strings for some reason. This is what I have so far and I am not sure where to go from here. Should I use a do loop to check through the input string until it is done seperating the words? And how should I go about doing that?
import java.util.Scanner;
public class P8
public static void main( String args[] )
char choice;
String line = null;
String answer = null;
Scanner scan = new Scanner(System.in);
do
System.out.println();
System.out.print("ENTER TextSpeak sentence(s): ");
line = scan.nextLine();
System.out.print( "Converted to English: \t ");
System.out.print( textSpeaktoEng( line ) );
System.out.println();
System.out.print("Want more TextSpeak?\t\t ");
answer = scan.next();
choice = answer.charAt(0);
if( scan.hasNextLine() )
answer = scan.nextLine();
}while(choice != 'N' && choice != 'n');
public static String textSpeakToEng(String s)
String engStr = null;
if( Character.isUpperCase( s.charAt(j) ) )
engStr += ? ?;
engStr += Character.toLowerCase( s.charAt(j) );
scan.close();
}I got my program to compile and run but I have a problem. If I input something like "ThisForumIsGreat" it will output just "t f i g" in lower case letters. Any suggestions?
import java.util.Scanner;
public class P8
public static void main( String args[] )
char choice; // Repeat until n or N
String line = null; // Sentences to toTextSpeak
String answer = null; // Repeat program scan
Scanner scan = new Scanner(System.in); // Read from keyboard
do
System.out.println();
System.out.print("ENTER TextSpeak sentence(s): ");
line = scan.nextLine(); // Read input line
System.out.print( "Converted to English: \t ");
System.out.print( textSpeakToEng( line ) );
System.out.println();
System.out.print("Want more TextSpeak?\t\t ");
answer = scan.next(); // Read line, assign to string
choice = answer.charAt(0); // Assign 1st character
if( scan.hasNextLine() ) // <ENTER> character
answer = scan.nextLine(); // Read line, discard
}while(choice != 'N' && choice != 'n'); // Repeat until input start n or N
public static String textSpeakToEng(String s)
String engStr = null;
int i;
for ( i = 0; i < s.length(); ++i )
if( Character.isUpperCase( s.charAt(i) ) )
engStr += " "; // Append 1 blank space
engStr += Character.toLowerCase( s.charAt(i) ); // Append lowercase
return( engStr );
} -
Can we use Iteartor with String[ ] a
Hii javaites
Can somebody tell me wht is the differnce between
String[ ] a & String a[ ],
and can we use Iterator with String[ ]a .
Plz tell me some code to transeverse through a ;
Thanximport java.util.Arrays;
import java.util.Iterator;
public class StringIt {
public static void main(String[] args) {
// two ways of declaring string arrays
String strArrA[], strB;
String[] strArrC, strArrD;
// the first would declare an array and a string
strArrA = new String[] {"a", "string", "array"};
strB = "Just a string";
// the second would declare two arrays
strArrD = new String[] {"another", "string", "array"};
strArrC = strArrD;
// "old fashioned" iteration through an array
for(int ndx = 0; ndx < strArrC.length; ndx++) {
System.out.println(strArrC[ndx]);
// you can use Iterator, but why?
Iterator<String> it = Arrays.asList(strArrC).iterator();
while(it.hasNext()) {
System.out.println(it.next());
// array iteration the new way! The Iterator is
// still being used, but is "hidden"
for(String str :strArrC) {
System.out.println(str);
}
Maybe you are looking for
-
I have a 6th generation iPod Nano. I almost exclusively use it as an FM radio and as a pedometer -- so far I have not loaded any songs onto it for listening, nor do I intend to in the future. Here's my problem: When my Nano runs out of juice, I have
-
How to store legal site ?
I don't know where to put in www.electrabel.be as a save website, so I don't receive further submenu that this site from www.electrabel.be is not saved... I cannot find where to put in this save website, normally via Internet options - Trusted websit
-
Forums Displaying in Spanish in Internet Explorer
For some reason all of a sudden, msdn.microsoft.com is displaying in Spanish when I open the site in Internet Explorer! I've changed nothing in my settings whatsoever. The English page displays fine in Chrome. I have no idea what's going on or what c
-
S10 Loads Bios then Stops, have to Hit Any Key to Load Windows XP
I have a Lenovo S10, after powering on, the just loads the bios screen of LENOVO. With the F2 & F12 at the bottom of the screen. If you press F2 to setup & F12 to Boot Menu, it will do so. When you press other keys, it will then load windows xp.
-
Hi, In a BPEL process I am working on there is an assignment activity where I assign the count of nodes as a result of a database query. This assignment is failing and am not able to figure out why. Here is the bpel fragment for the assignment *<assi