OT(slightly): SmartQuotes

Our functional specs are written in MS Word and we often copy error
messages from those docs and paste them in our code in IDEA. The problem
is, if the writer had smartquotes(curly quotes), which is an autoformat
"feature" of Word, in it, they get transfered to our code and some
browsers don't recognize them. They are very hard to find in code by
"eye". My question is: Is there a way make IDEA highlight them or
convert them or better yet, not allow them?

--
"A man's ethical behavior should be based effectually on sympathy,
education, and social ties and needs; no religious basis is necessary.
Man would indeed be in a poor way if he had to be restrained by fear of
punishment and hope of reward after death."
[Albert Einstein, "Religion and Science", New York Times Magazine, 9
November 1930]

4 comments
Comment actions Permalink

Brad wrote:

Our functional specs are written in MS Word and we often copy error
messages from those docs and paste them in our code in IDEA. The problem
is, if the writer had smartquotes(curly quotes), which is an autoformat
"feature" of Word, in it, they get transfered to our code and some
browsers don't recognize them. They are very hard to find in code by
"eye". My question is: Is there a way make IDEA highlight them or
convert them or better yet, not allow them?

>
This is likely because Word, and IDEA on Windows uses cp1252 (AKA windows-1252) as text encoding. Browsers commonly use iso-8859-1,
which cp1252 is a superset of. cp1252 defines characters like "curly quotes" for the codepoints 128-159, which are undefined in
iso-8859-1.

Possible workarounds:
Use UTF-8 for encoding files.
Don't use MS Word.
Don't use Windows.
Turn off dum... err, "smart quotes" in MS Word.
Tell the browser to use a different encoding. (For mozilla: "View" -> "Character encoding")
Tell the browser that the html file is in cp1252, with a meta tag:
]]>

/Kreiger



Attachment(s):
signature.asc
0
Comment actions Permalink

I don't have the option to do 1-5. We get our specs from BSAs who, I'm
sure, will not switch to some other text editor because of this problem.
And we can't tell our customers to use a different encoding in their
browsers. 6 is a viable option but I'd rather just get rid of the curly
quotes.

Christoffer "Kreiger" Hammarström wrote:

Brad wrote:

>> Our functional specs are written in MS Word and we often copy error
>> messages from those docs and paste them in our code in IDEA. The problem
>> is, if the writer had smartquotes(curly quotes), which is an autoformat
>> "feature" of Word, in it, they get transfered to our code and some
>> browsers don't recognize them. They are very hard to find in code by
>> "eye". My question is: Is there a way make IDEA highlight them or
>> convert them or better yet, not allow them?
>>

This is likely because Word, and IDEA on Windows uses cp1252 (AKA
windows-1252) as text encoding. Browsers commonly use iso-8859-1,
which cp1252 is a superset of. cp1252 defines characters like "curly
quotes" for the codepoints 128-159, which are undefined in
iso-8859-1.

Possible workarounds:
Use UTF-8 for encoding files.
Don't use MS Word.
Don't use Windows.
Turn off dum... err, "smart quotes" in MS Word.
Tell the browser to use a different encoding. (For mozilla: "View" ->
"Character encoding")
Tell the browser that the html file is in cp1252, with a meta tag:
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">

/Kreiger


--
"A man's ethical behavior should be based effectually on sympathy,
education, and social ties and needs; no religious basis is necessary.
Man would indeed be in a poor way if he had to be restrained by fear of
punishment and hope of reward after death."
[Albert Einstein, "Religion and Science", New York Times Magazine, 9
November 1930]

0
Comment actions Permalink

You could write an ant task that replace all the characters in your sources

something like :

]]>
<include name="*/.java"/>
ߣ

0
Comment actions Permalink

Thanks! That's what I was looking for. Actually, is there a "search" or
"find" ant task so I can see what's going to change before it changes?

BoD wrote:

You could write an ant task that replace all the characters in your sources

something like :

<replace dir="${dest.webapp}/jsp" summary="true">
<include name="*/.java"/>
<replacetoken>&#2019;</replacetoken> <!-- replace by real value
<replacevalue>'</replacevalue>
</replace>


You could also write an inspection plugin that highlight it in the code,
but I think that's a bit "overkill" :)

BoD



Christoffer "Kreiger" Hammarström wrote:

>> Brad wrote:
>>
>>> Our functional specs are written in MS Word and we often copy error
>>> messages from those docs and paste them in our code in IDEA. The problem
>>> is, if the writer had smartquotes(curly quotes), which is an autoformat
>>> "feature" of Word, in it, they get transfered to our code and some
>>> browsers don't recognize them. They are very hard to find in code by
>>> "eye". My question is: Is there a way make IDEA highlight them or
>>> convert them or better yet, not allow them?
>>>
>> This is likely because Word, and IDEA on Windows uses cp1252 (AKA
>> windows-1252) as text encoding. Browsers commonly use iso-8859-1,
>> which cp1252 is a superset of. cp1252 defines characters like "curly
>> quotes" for the codepoints 128-159, which are undefined in
>> iso-8859-1.
>>
>> Possible workarounds:
>> Use UTF-8 for encoding files.
>> Don't use MS Word.
>> Don't use Windows.
>> Turn off dum... err, "smart quotes" in MS Word.
>> Tell the browser to use a different encoding. (For mozilla: "View" ->
>> "Character encoding")
>> Tell the browser that the html file is in cp1252, with a meta tag:
>> > charset=windows-1252"> >> >>]]> /Kreiger

--
"A man's ethical behavior should be based effectually on sympathy,
education, and social ties and needs; no religious basis is necessary.
Man would indeed be in a poor way if he had to be restrained by fear of
punishment and hope of reward after death."
[Albert Einstein, "Religion and Science", New York Times Magazine, 9
November 1930]

0

Please sign in to leave a comment.