Writing strings containing \0 characters into a TextField

Hi,
I have a string containing one or more '\0' characters. I need to write it into a TextField and, for the purpose, I use the setText method.
What I get then is a substring containing only the characters before the first \0.
If I use a JTextField then I am able to see all the characters but if I try to copy and paste the content of the JTextField (using CTRL-C and CTRL-V) I get again a substring terminated by the first \0.
Could someone help me?

Hello again,
I wrote this program that will copy from one JTextField to another. are you trying to past to another application, if I past the string into ultraedit (text editor) I get the first word, I can't see a way around that?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class SimpleApp extends JFrame {
public static void main(String args[]) {
SimpleApp aFrame = new SimpleApp();
JTextField myTextField = new JTextField("one\0two\0three\0four\0");
JTextField myTextField2 = new JTextField();
public SimpleApp() {
super("Frame");
getContentPane().setLayout(new BorderLayout());
setResizable(false);
myTextField.setColumns(30);
myTextField2.setColumns(30);
getContentPane().add(myTextField, "Center");
getContentPane().add(myTextField2, "South");
pack();
show();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
}

Similar Messages

  • How to find out whether the String contains chinese characters

    I need to check if the string contains chinese characters in Java. Does anyone know how to do it? thx.

    Since Java strings contain UNICODE code points, check the content against the relevant page here - http://www.unicode.org/charts/ .

  • Entering Scandinavian characters into AWT TextField

    I have a problem entering Scandinavian characters, ���, into AWT textfields. All I get is squares. The entered text, sent to a database, is not stored correctly either, so it is not just a display problem.
    But then, I can copy-paste (both select - middle button, and ctrl-c - ctrl-v) these characters without problems, both from other fields within the application and from other X11 applications.
    This is on Linux, I do not have a possibility to test on Windows.

    You can also use KeyListener. You can also search the forum as this question has been asked numerous times.

  • Passing a wchar_t* containing asian characters into java

    I tried converting the wchar_t* into jstring in C, then passing that jstring into java, however, even though when I write the wchar_t* into a file, the asian characters read fine, the jstring in java becomes ????????????. Then I tried narrowing the wchar_t* into char*, then converting into jstring and passing that. Similarly, the char*, when written to a file, contains the proper asian characters, but when read in java, becomes ????????????.
    Any help is appreciated!

    ejp wrote:
    Java strings contain UTF8.Java Strings contain UTF-16.True - I was thinking more of GetStringUTFChars when I said that.
    A wchar is not even necessarily 8 bitsA wchar_t is necessarily at least 16 bits taking ISO/IEC 14882:1998 standard #3.9.1.5 into account.
    Interesting - I will look that up. The following discussion would seem to disagree with that however.
    [http://www.velocityreviews.com/forums/t289787-is-wchar_t-guaranteed-to-be-larger-than-char.html]

  • Best way to split a single string containing 2 words into word1 and word2

    Whats the best way to take a string containing 2 words and split it into 2 strings ?
    eg. "red ferrari"
    string1 "red"
    string2 "ferrari"

    If your list is always going to have exactly two words, then yes.  Otherwise it depends on your requierments.

  • How to replace string containing special characters by another string

    Hi all,
    I have to Search for a pattern and replace it by a substitute pattern [Eg: Replace methodOrig (a,b) with  SessTime = getSessionParameter(time);  methodNew(a,b,SessTime) ] in files.
    i tried this using replace(),but it din't work since string1 contains special characters.
    can anyone help me asap.
    thanks in advance.

    Double-post: http://forum.java.sun.com/thread.jspa?threadID=599211&tstart=0

  • How to parse a string containing xml data

    Hi,
    Is it possible to parse a string containing xml data into a array list?
    my string contains xml data as <blood_group>
         <choice id ='1' value='A +ve'/>
         <choice id ='2' value='B +ve'/>
             <choice id ='3' value='O +ve'/>
    </blood_group>how can i get "value" into array list?

    There are lot of Java XML parsing API's available, e.g. JAXP, DOM4J, JXPath, etc.
    Of course you can also write it yourself. Look which methods the String API offers you, e.g. substring and *indexOf.                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to do string contains in drools.

    hi everyone
    i'm using drools for a project and have come to a problem. in two of my rules i need to check if a string contains some characters but can't seem to do get the rules to be excepted. if anyone could help me i would be very grateful.
    thanks in advance
    mike

    Display the rules.

  • Why does text on certain portions of websites, usually when adjacent text contains special characters, become jumbled into seemingly random sets of characters that are not in any way jumbled when viewing the source of the webpage? How can I fix this?

    When viewing most text on most websites, it displays properly. However, there are two instances where text will either tend to, or consistently, become jumbled into a mess of seemingly random characters. Oddly enough, these seemingly random characters are not, in fact, random. The same weird character will be used to replace the same regular English text character consistently across the entire area that has been jumbled.
    The two instances where this tends to occur most often, or consistently in some cases, are, first, when a paragraph or particular section of formatted text contains special characters, such as Chinese or Japanese characters, or accented letters. When this happens, usually the paragraph that contains the special characters is completely jumbled, while the rest of the text on the page will have intermittent jumbling on a word or two. Most often, the word "the" is jumbled in this case.
    The second instance where this happens is when a website uses specially formatted text in some form or another. I, not being an expert at web development, am not sure what kind of formatting causes it, but I can provide consistent examples in lieu of my experience:
    - Example 1:
    [http://img408.imageshack.us/img408/9564/firefoxcharencodingissu.jpg]
    Example 1 shows a portion of a screen-shot of the website "Joystiq.com". Every single article title on the front page of this blog is consistently jumbled, while the text of the article itself remains untouched. Please note that when this jumbled text is highlighted, it is visible un-jumbled in the right-click menu as well as in the source code of the page. Other consistent instances can be found within many search fields on various websites. For instance, the search bar located at the top right of "Kotaku.com" consistently displays jumbled characters both on its default text of "Search" and on any text that is typed into the search box itself.
    - Example 2:
    [http://img822.imageshack.us/img822/9564/firefoxcharencodingissu.jpg]
    Example 2 shows both the jumbling of the paragraph containing the character "☆" as well as the subsequent peppering of the rest of the article's text with small jumbled words. Below this is the DOM Source of the selected text which shows how the text itself is being rendered properly within the site's source. Additionally, for convenience, I have edited on to the bottom of the image a small snippet of what the search bar on the same page looks like. Notice how the grayed-out text that normally would read "Search" is instead jumbled.
    This issue has been plaguing my browser for the past year or so, and I had hoped that it would go away with subsequent Firefox updates. It has not gone away.
    Thank you for reading! Please help!

    This issue can be caused by an old bitmap version of the Helvetica or Geneva font or (bitmap) fonts that Firefox can't display in that size.
    Firefox can't display some old bitmap fonts in a larger size and displays gibberish instead.
    You can test that by zooming out (View > Zoom > Zoom Out, Ctrl -) to make the text smaller.
    Uninstall (remove) all variants of that not working font to make Firefox use another font or see if you can find a True type version that doesn't show the problem.
    There have also been fonts with a Chinese name reported that identify themselves as Helvetica, so check that as well.
    Use this test to see if the Helvetica font is causing it (Copy & Paste the code in the location bar and press Enter):
    <pre><nowiki>data:text/html,
    Helvetica<br><font face="Helvetica" size="25">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</font><br>
    Helvetica Neue<br><font face="Helvetica Neue" size="25">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</font>
    </nowiki></pre>
    You should reset the network.http prefs that show user set on the about:config page.<br />
    Not all websites support http pipelining and if they do not then you can have issues with images or other problems.
    See also http://kb.mozillazine.org/Images_or_animations_do_not_load#First_steps

  • Flatten to string for sending through TCP/IP contains CRLF characters

    Hi,
    I'm using a 'flatten to string' function to send some data through TCP/IP.
    To minimise delays, I use the CRLF mode so that the receive function returns as soon as it receives a CRLF sequence (termination character).
    I noted that every now and then only part of the data is transmitted because the flattened string itself sometimes (albeit rarely) contains CRLF characters.
    I was wondering if this is correct behaviour, or if I'm missing something.I expected flatten to string to produce pure ASCII strings without special characters.
    Now I first have to scan the string and replace possible CRLF characters by some known series of characters and do the opposite on the receiving side, and hope that this particular sequence never occurs.
    Any comment is appreciated,
    Manu
    Certified LabVIEW Developer (CLD)
    Solved!
    Go to Solution.

    mkdieric wrote:
    Hi,
    thanks for the feedback. I'll use the way you describe, by first sending the number of characters to expect.
    Manu
    Make sure you are consistent with the format for the number of butes. That is, always use an 8, 16 or 32 bit value. Which one you use is up to you and will depend on the size of your data. A 32 bit value is the most common size to use. Anyway what I am basically saying is that if you are inconsistent with what size number you use for the size you will get inconsistent results when you read the data since you will be interpretting the size incorrectly some of the time.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Converting String Characters into Regular Expression Automatically?

    Hi guys.... is there any program or sample coding which is available to convert string characters into regular expression automatically when the program is run?
    Example:
    String Character Input: fnffffffffffnnnnnnnnnffffffnnfnnnnnnnnnfnnfnfnfffnfnfnfnfnfnnnnd
    When the program runs, it automatically convert into this :
    Regular Expression Output: f*d

    hey guys.... i am sorry for not providing all the information that you guys need as i was rushing off to urgent meeting... for my string characters i only have a to n.. all these characters are collected from sensors and stored inside database... from many demos i have done... i found out that every demo has different strings of characters collected and these string of characters will not match with the regular expressions that i had created due to several unwanted inputs and stuff... i have a lot of different types of plan activities and therefore a lot of regular expressions.... if i put [a-z|0-9]*... it will capture all characters but in the same time it will be showing 1 plan only.... therefore, i am finding ways to get the strings i collected and let it form into regular expression by themselves in the program so that it will appear as different plans as output with comparing with the regular expression that i had created.... is there any way to do so?
    please post again if there is any questions u are still not familiar with... thank you...

  • Is it possible to search for strings containing spaces and special characters?

    In our RoboHelp project, there are figures with text labels such as Figure 1, Figure 3-2, etc.
    When I search for "Figure 3" I get all pages containing "Figure" and "3", even if I surround it in quotes.  Similarly, searching for "3-2" treats the '-' character as a space and searches for all pages containing '3' or '2'.
    Is there a way to search for strings containing spaces and special characters?

    In that case I think the answer is no if you are using the standard search engine. However I believe that Zoom Search does allow this type of searching. Check out this link for further information.
    http://www.grainge.org/pages/authoring/zoomsearch/zoomsearch.htm
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Encode/Decode a String containing Chinese etc. characters to/from unicode

    Hi, I am working to encode a multilingual String (English, chinese, japanese, Latin etc) as unicode. The encoded string is used as follows
    1)decoded by the User Interface for display purpose. The user interface is a web UI and
    2)read by user. So it should be human readable when it contains only English and special characters.
    Thus having a string that contains letters from English, Japanese, CHinese etc, we want the Japanese/Chinese characters to be encoded by the hex values such as &#31169; be encoded as %E7%A7%81.
    However, it is preferable that other special characters like ! ? , space etc not be encoded and left as such.
    The encoding of characters is achievable by using Java.net.URLEncoder but it also replaces all special characters including space character, which becomes a pain for the reader.
    Unfortunately URLEncoder.java does not have any API to configure which characters to encode. Any suggestions how I can proceed, or what encoder i can use?
    Thanks in advance!
    Regards

    I have to say that I disagree that "%E7%A7%81" is "human-readable". On the contrary, I would say that "&#31169;" is human-readable; even though I don't understand it myself, there are a lot of humans who do.
    But let's say that "human-readable" wasn't the right term. Maybe you just wanted a representation of an arbitrary Unicode string in ASCII characters only. In which case I would recommend Base-64 encoding. It does make everything unreadable, though, whereas your requirements appear to be to only make languages other than English be unreadable. So if you don't like that you are going to have to write your own encoder.
    Note also that your original premise:
    Hi, I am working to encode a multilingual String (English, chinese, japanese, Latin etc) as unicode.is misguided, since all data in Java Strings is already Unicode characters.

  • How to validate string that contains special characters.

    Hi,
    I am new to Data Services.I took excel sheet as a data source .Now i have do some validation functions like vendorgroup should not contain special characters ,name cleansing operations etc.. So,please anyone help me redarding this.
    Thanks in advance

    Anonymous,
    No this is not a bug. Working with multi-select lists or any item which stores colon delimited values can be tricky to work with in APEX. There are a few work arounds for this. One is to replace the colons with something else like you described and then replace the colons on the landing page. Another solution is to send the primary key for that record and have an automatic row fetch or a computation pull the colon delimited value.
    Cheers,
    Tyson Jouglet

  • Can you parse an array of string characters into separate arrays?

    Hello,
    I didn't see anything directly related to my question, so I'll go ahead and post it.  I'm looking to parse an array of hex characters into three separate arrays for parallel Color to RGB conversion in LabView.  Ideally, after importing an image, I would have liked to use the Color to RGB conversion for the 24-bit pixmap (in hex digit format), but apparently, you can only do this for single number conversions...not arrays.  Another way is what I have mentioned above, which would be to parse each element's red, green, and blue # into three separate arrays as shown below:
    Original Array:   aa11ff     225599
                              cc4488   bbcc11
    Array 1: aa  22
                 cc   bb
    Array 2: 11   55
                  44   cc
    Array 3:  ff    99
                  88   11
    I could then do a parallel conversion of these arrays from hex to numeric and get the desired result.  However, I'm having trouble finding a function that will do this.  So I would like to ask if a function like this does exist and if so, what is it?  I should note that I'm trying to avoid using two while loops because of time constraints (using the program for in-situ measurements), and we do not own, nor are we looking to purchase the $$$ vision/video package that NI makes.

    Nevermind.  I found an adequate way.

Maybe you are looking for

  • Can I install Oracle 8.1.6 on RH LINUX 7.1

    Can i Install Oracle 8.1.6 on Redhat Linux 7.1

  • OS X get "frozen" often while I run in internet ...

    Hi people, I remark that in that often my mac get "frozen" suddenly and I have to restart holding down the power key for few seconds..that's happend also 5-6 time pro day..sometimes less. After restarting, it says that OS X shut down and ask me to se

  • Calling a vi in scilab script

    Hello! What I'm trying to do here is the following: I am developping a VI that uses a certain algorithm to function. I put the algorithm into a Scilab script structure, no problem here I already did that. The problem is, during the execution of the s

  • Parameter with chekbox option

    Hi, i am working on siebel BI publisher report. I am able to display parameter value on the report. Now i wanted to do some logical thing based on parameter value. for example: if user passes parameter value as check box selected then i have to call

  • Relay denied exception!! Why can i do the same with sendmail???

    Hi, Everytime I try to send email from my code, I get the following exception: class javax.mail.SendFailedException: 550 5.7.1 <[email protected]>... Relaying denied But if I try to use sendmail and send email to the same address with the same SMTP h