>> I am interested in your MS Word cleaner.
>> Actually, I would like to see it right away if it is possible.
>> Regards,
>> Dennis Myr�n
Hi Dennis,
Here is the function I just coded to resolve my issue with the Word's
specific characters (appearing as # in the resulting PDF). As I said, I
did'nt find any complete table of the M$ Word's specific characters, so
this function is not complete at all, but it is enought for my problem !
And it's not optimised at all, but it didn't slow my process so much !
A stupid java question, should I make a first test like :
if ((source.indexOf(0x85) < 0) &&
(source.indexOf(0x91) < 0) &&
(source.indexOf(0x92) < 0) &&
(source.indexOf(0x93) < 0) &&
(source.indexOf(0x94) < 0) &&
(source.indexOf(0x20) < 0) &&
(source.indexOf(0x96) < 0) &&
(source.indexOf(0x9C) < 0)) {
stBuffer.append(c);
}
Cheers,
Simon
//-----------------------------------------------------------------------------------
/**
* Clean the MS Word characters in the <code>String</code> object given as
parameter.
*
* @param source The <code>String</code> object to format.
* @return A new formatted <code>String</code> object.
*/
public static String formatWord2K(String source) {
String output = source;
if ((source.indexOf(0x85) > 0) ||
(source.indexOf(0x91) > 0) ||
(source.indexOf(0x92) > 0) ||
(source.indexOf(0x93) > 0) ||
(source.indexOf(0x94) > 0) ||
(source.indexOf(0x20) > 0) ||
(source.indexOf(0x96) > 0) ||
(source.indexOf(0x9C) > 0)) {
StringBuffer stBuffer = new StringBuffer();
int len = source.length();
for (int i = 0; source != null && i < len; i++) {
char c = source.charAt(i);
// Replace the Word's (...) character (0x85).
if (c == 0x85) {
stBuffer.append("...");
}
// Replace the Word's (' and ') characters (0x91 et 0x92).
else if (c == 0x91 || c == 0x92) {
stBuffer.append("'");
}
// Replace the Word's (" et ") characters (0x93 et 0x94).
else if (c == 0x93 || c == 0x94) {
stBuffer.append('"');
}
// Replace the Word's (?) character (0x96).
else if (c == 0x96) {
stBuffer.append("-");
}
// Replace the Word's hard space (�) character (0x20).
else if (c == 0x20) {
stBuffer.append(" ");
}
// Replace the Word's (?) character (0x9C).
else if (c == 0x9C) {
stBuffer.append("oe");
}
else {
stBuffer.append(c);
}
}
output = stBuffer.toString();
}
return output;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]