This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

retain apostrophe in Collection object

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a TreeSet of values. One value contains an apostrophe. When the contents of the TreeSet are listed, instead of an apostrophe, it displays another character. I tried changing the TreeSet to an ArrayList, with the same result. How do I get around this?



results:

DRAINS
IVÆS,
TUBES

I really need the output to match what I have listed above. Any tips are greatly appreciated. Thanks in advance.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't address your question, but does the IV own something? That's the only reason I can see why you would type "IV'S", as in "The IV's line to the bag".

If you are talking about more than one IV, it would be "IVs" or "IVS".
 
Marshal
Posts: 78695
374
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the Unicode value of that apostrophe? Is it \u0027 (') or \u2019 (’)? If you simply push the key, you usually get \u0027.
 
Ranch Hand
Posts: 37
Oracle Tomcat Server Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What is the Unicode value of that apostrophe? Is it \u0027 (') or \u2019 (’)? If you simply push the key, you usually get \u0027.


You may be able to just use the Unicode value of the troublesome value. For example, if it's \u2019 your code would look like this:
 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
fred rosenberger: Thanks for the reply. Unfortunately, this data is dictated by the system. The presence of the apostrophe in the data is outside of my control. I have to accommodate it.

Eli Wood and Campbell Ritchie: I will be loading these values dynamically, so I won't be able replace the apostrophe with the Unicode value. I tried to do this programmatically:


which prints:

IVÆS,

so this didn't work. Did I use the regex above incorrectly?

Are there any other ways to make this work? This is urgent, so I appreciate your responses.
 
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I blame your command prompt. Most shells, including Windows' command prompt, can't display most characters that aren't extended ASCII.

verduka fox wrote:This is urgent


Please EaseUp. There is no "urgent" around here.
 
Marshal
Posts: 28007
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

verduka fox wrote:Are there any other ways to make this work? This is urgent, so I appreciate your responses.



At the command line? No. If you're writing a command-line application and you have to support characters outside of whatever your shell supports, you're out of luck.

But are you writing a command-line application? If you aren't, then don't use the shell to do that sort of testing. It just confuses things. Use whatever medium the application is targeting (Swing GUI, web app, whatever) to do that testing.
 
Campbell Ritchie
Marshal
Posts: 78695
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote: . . . Most shells, including Windows' command prompt, can't display most characters that aren't extended ASCII. . . . .

That is why I thought they were using \u2019. But that would surely come out on Windows® as ?

Æ is \u00c6, and I can't find any sort of apostrophe that is C6, not even in EBCDIC.
 
Rob Spoor
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Rob Spoor wrote: . . . Most shells, including Windows' command prompt, can't display most characters that aren't extended ASCII. . . . .

That is why I thought they were using \u2019. But that would surely come out on Windows® as ?


I wouldn't count on that. Applications like Word can handle it, Windows' command prompt is quite limited in what it can display. \u2019 is definitely not one of them.

Æ is \u00c6, and I can't find any sort of apostrophe that is C6, not even in EBCDIC.


When Windows' command can't print out the character, it can print out anything. For instance, if I print out both \u2019 and \u00c6 I get Æ and ã. Go figure!
 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My code is actually running on WebSphere Portal on AIX. When it runs there, the apostrophe is displayed as a question mark '?' instead of an apostrophe. When I'm debugging this on Windows, Windows displays the apostrophe as Æ. In either case, the apostrophe I specify in the code is not displayed as such. How do I get the code when run to display what is actually written in the code?

PS Sorry for the urgent comment. I didn't mean to upset anyone.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I will be loading these values dynamically, so I won't be able replace the apostrophe with the Unicode value.



You should be able to replace those dispicable MS Word "smart" punctuation marks dynamically with regex.

I would use an editor capable to displaying hex values to see exactly what the bogus apostrophe code is.

Looking back at how I solved the problem, I used the String replace function - which is faster - like this:



When you find out what the "apostrophe" code is, just add a line.

Bill
 
Campbell Ritchie
Marshal
Posts: 78695
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Display it on a Java™ platform.
 
Rob Spoor
Sheriff
Posts: 22773
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Looking back at how I solved the problem, I used the String replace function - which is faster - like this:


I would actually not use String.replace but loop. Your code loops over the String 12 times, potentially creating 12 new Strings. One single loop will suffice:
As in your code, replacing another character is easy: just add one case statement with replacement.
 
It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic