Converting String containg \t to char
I have a string with the value "\t". The tab symbol. How can I convert this to a char?
I tried this, but it didn't work:
String tab = "\\t";
char[] chars = new char[5];
tab.getChars(0, tab.length(), chars, 0);
char tabchar = chars[0];
But tabchar is always just equal to \
Any ideas?
Thanks,
Tyso
\\t - two chars (\ and t)
\t - one char (tab (9))
try this:
String tab = "\t";
char[] chars = new char[5];
tab.getChars(0, tab.length(), chars, 0);
char tabchar = chars[0];
[\code]
Similar Messages
-
Convert String from ASCII to ANSI
Hi,
a command line instruction via LabVIEW function "System Exec.vi" retrieves me a string in ASCII format. Is there a function to convert string from ASCII to ANSII format? I use LabVIEW 8.5 German Installation.
Kind Regards
Christian
Test Engineering
digades GmbH
www.digades.comHallo Christian,
AFAIK there is no such in function in LabView...
But you can:
- use "Search and replace string" to search for ASCII chars and replace them by their corresponding ANSI char, do this in a loop for all chars to be replaced (acceptable speed for small strings...)
- convert the string to an U8 array and use a lookup table to convert all bytes from ASCII to ANSI, convert back to string (may be faster for long strings...)
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Converting a byte[] into a char[]
Hi All,
what's the best way to convert a byte[] into a char[]?
Any advice appreciated. Thanks in advance.you will need a encoding schema...
byte is binary data, char is interpret from byte by the system...
easiest way without extra coding...
new String(byte[], encoding).toCharArray()
if you don't specify encoding... system default is used. -
Converting String to byte array
Hi,
There is a code for converting String to byte array, as follows:
public byte[] toByteArray(String s)
char[] c = s.toCharArray();
int len = c.length;
byte[] b = new byte[len * 2];
for ( int i = 0 ; i < len ; i++ )
b[i * 2] = (byte)(c);
b[(i * 2) + 1] = (byte)(c[i] >> 8);
return b;
But this isn't doing the conversion properly. For example, for the � (euro) symbol, it converts to some other unreadable symbol. Also, same is the case for square brackets. Any idea why this' so? What's wrong with the above code?
The encoding format is UTF-8.
Thanks.> In fact, I tried with String.getBytes() too, but leads to the same problem, with those specific symbols.
Did you try the String.getBytes(String charsetName) method?
Both methods have been around since Java 1.1.
It's an extremely important skill to learn to read the API and become familiar with the tools you will use to program Java. Java has an extensive set of online documentation that you can even download for your convenience. These "javadocs" are indexed and categorized so you can quickly look up any class or method. Take the time to consult this resource whenever you have a question - you'll find they typically contain very detailed descriptions and possibly some code examples.
Java� API Specifications
Java� 1.5 JDK Javadocs
Best of luck!
~ -
JavaMapping: Convert String to OutputStream?
Hi everybody,
how can I convert a String to OutputStream?
Thanks, Regards MarioYou have to convert String to OutputStream by means of using getBytes() method..
See the example
public void execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
outputstream.write("<?xml version = '1.0' encoding = 'utf-8'>".getBytes());
outputstream.write(<ns0:outputinfo ns0=\urn:xyz\File_File\>".getBytes());
String newline=null;
BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));
StringBuffer sb = new StringBuffer();
while(newline = br.readLine())!=null)
String empno=null;
String empname=null;
String native=null;
char[] chr = new char[100];
chr = newline.toCharArray();
String[] data = new String[10];
int a = 0;
int b = 2;
for(int i=0;i<newline.length(); i++)
if(chr<i>==',')
data[a]=newline.substring(b,i);
a=a+1;
b=i+1; }
empno=data[0];
empname=data[1];
native=data[2];
outputstream.write("<Data>".getBytes());
outputstream.write("<Record>".getBytes());
outputstream.write(("<EmpNo>"empno"</Empno>").getBytes());
outputstream.write(("<EmpName>"empname"</Empname>").getBytes());
outputstream.write(("<Native>"native"</Native>").getBytes());
outputstream.write(("</Record>".getBytes());
outputstream.write("</Data>".getBytes());
outputstream.write("</ns0:outputinfo>".getBytes());
br.close();
inputstream.close();
outputstream.close(); -
Not able to convert string attribute to number and date please help me out
not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out
Hi,
You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
regards,
Nick -
Convert String to Date and Format the Date Expression in SSRS
Hi,
I have a parameter used to select a month and year string that looks like: jun-2013
I can convert it to a date, but what I want to do is, when a user selects a particular month-year (let's say "jun-2013")
I populate one text box with the date the user selected , and (the challenge Im having is) I want to populate a text box next to the first text box with the month-year 2 months ahead. So if the user selects
jun-2013 textbox A will show jun-2013
and textbox B will show aug-2013..
I have tried:
=Format(Format(CDate(Parameters!month.Value ),
"MM-YYYY" )+ 2 ) -- But this gives an error
This returns the month in number format like "8" for august...
=Format(Format(CDate(Parameters!month.Value ),
"MM" )+ 2 )
What is the proper syntax to give me the result in this format = "aug-2013" ???
Thanks in advance.
MC
M CollierYou can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
In your case, the code would be something like:
var sDate = "2013-01-10";
// Convert string to date
var oDate = util.scand("yyyy-mm-dd", sDate);
// Convert date to new string
var sDate2 = util.printd("mm/dd/yyyy", oDate);
// Set a field value
getField("date2").value = sDate2;
The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started. -
Convert String variable value to an Object referece type
Hi all,
I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
Let's think that there is a string variable name like,
String name="HelloWorld";
and there is a class name same to the variable value.
class HelloWorld
I am passing this string variable value to a method which is going to make a object of helloworld;
new convertobj().convert("HelloWorld");
class convertobj{
public void convert(String name){
// in hert it is going to create the object of HelloWorld;
// HelloWorld hello=new HelloWorld(); just like this.
now i want to do this from the name variable value.( name na=new name()) like wise.
please let me know if there any possible way to do that.
I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
thanx.Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
John -
How to convert string to an integer in SQL Server 2008
Hi All,
How to convert string to an integer in sql server,
Input : string str="1,2,3,5"
Output would be : 1,2,3,5
Thanks in advance.
Regards,
SunilNo, you cannot convert to INT and get 1,2,3 BUT you can get
1
2
3
Is it ok?
CREATE FUNCTION [dbo].[SplitString]
@str VARCHAR(MAX)
RETURNS @ret TABLE (token VARCHAR(MAX))
AS
BEGIN
DECLARE @x XML
SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
INSERT INTO @ret
SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
FROM @x.nodes('//t') x(i)
RETURN
END
----Usage
SELECT * FROM SplitString ('1,2,3')
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date
Hi
Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
Thankshttp://javaalmanac.com/egs/java.text/FormatDateDef.html
Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html) -
Facing problem in converting string to date using getOANLSServices()
I am trying to set a value for date field in my vo and trying to insert into the table.
In controller I am getting the String which has a date:
ex: String date="01-NOV-2007";
while setting into the row I need to convert into Date but it is returning null.
The below code I used
to convert into date :
Date dt = new Date(getOADBTransaction().getOANLSServices().stringToDate(date));
But this dt is returning a null value is there any solution please advise me.
Regards!
SmarajeetSmarajeet ,
See this thread, in one of my replies i have mentioned how to convert string to java.sql.date.You can use the same for oracle.jbo.domain.Date.
urgent!How to set the default selected date for an OAMessageDateFieldBean
--Mukul -
Converting String To XML Format and send as attachment
Hi
My requirement is to convert String into XML Format and that XML File i have to send as an attachment
can any one one give solution for this Problem.
Thank you
Venkatesh.Khi,
i m filling the itab first and converting to xml
itab contaning these data
GS_PERSON-CUST_ID = '3'.
GS_PERSON-FIRSTNAME = 'Bill'.
GS_PERSON-LASTNAME = 'Gates'.
APPEND GS_PERSON TO GT_PERSON.
GS_PERSON-CUST_ID = '4'.
GS_PERSON-FIRSTNAME = 'Frodo'.
GS_PERSON-LASTNAME = 'Baggins'.
APPEND GS_PERSON TO GT_PERSON.
after conversion data is coming like that
#<?xml version="1.0" encoding="utf-16"?>
<CUSTOMERS>
<item>
<customer_id>0003</customer_id>
<first_name>Bill</first_name>
<last_name>Gates</last_name>
</item>
<item>
<customer_id>0004</customer_id>
<first_name>Frodo</first_name>
<last_name>Baggins</last_name>
</item>
</CUSTOMERS>
but errors are 1) # is coming at the first
2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
can anybody plz solve it.
regards,
viki -
Converting string to XML format
Hi All,
I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
<VALUE005>20387899.437</VALUE005>
<VALUE006>20387899.437</VALUE006>
Is there any function module for this.Chk this thread.
Re: Regd: File Conversion to XML format -
Converting string to xml in xslt
Hi we are trying to convert string to xml in xslt but it is getting errored out.
We have followed the procedure mentioned at http://download.oracle.com/docs/cd/A91202_01/901_doc/appdev.901/a88894/adx04xsl.htm under the section "How Do I Convert A String to a Nodeset in XSL?".
Standard procedure mentioned by oracle is not working. Is it a known bug?Chk this thread.
Re: Regd: File Conversion to XML format -
Converting string(which is an xml from the java side) to xml in flex
Hi,
I have an xml from the java side which i send as string over amf. I need to convert this to xmllist or xml and bind it to a tree. Could some one help me in doing this. My label field needs to be displayName
this is my xml that comes as string to the flex side
<Menu>
<MenuItem>
<id>1</id>
<displayName>Add</displayName>
<menuList>
<MenuItem>
<id>3</id>
<displayName>Form1</displayName>
<menuList/>
</MenuItem>
<MenuItem>
<id>4</id>
<displayName>Form2</displayName>
<menuList/>
</MenuItem>
</menuList>
</MenuItem>
<MenuItem>
<id>2</id>
<displayName>Delete</displayName>
<menuList>
<MenuItem>
<id>5</id>
<displayName>Form1</displayName>
<menuList/>
</MenuItem>
<MenuItem>
<id>6</id>
<displayName>Form2</displayName>
<menuList/>
</MenuItem>
</menuList>
</MenuItem>
</Menu>Well, for Binding you will probably need to further convert to XMLListCollection or ArrayCollection.
Not sure.
However, that is the way to convert String to XML.
Maybe you are looking for
-
How-to use Excel for the XML file input?
Hello all, Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion. In the comments section of this previous cited tutorial, Rufa
-
MMy Ipad was a gift from my wife years ago...an ipad 2 I believe. It originally was registered in her name and email so it was a suprise...I have since gotten most everything switched to my own Apple id account.My problem is with the iCloud...it stil
-
Business Rules and Planning Login Error
Hi Experts, Today with the help of our DBA we migrated all the Production Planning Oracle database to Planning development database. But after all, we restarted all the services and after that when we are connecting to the Console and Planning applic
-
I deleted a few pages from my Notes App. Is there a way to recover these deleted pages? Thanks
-
Should I buy iLife09 at this time or should I wait for iLife10 to come out?
Is iLife10 coming out any time soon? What about iWork10?