trouvailles
08-24-2003, 04:57 PM
I have a script that ensures there is always a space after a comma, a space and a capital letter after either a full stop, question mark or exclamation mark. It also removes excess spaces and capitalizes the first letter of a new line.
http://fslactivities.sd61.bc.ca/ezHTMLarea/popups/plaintext.html
This works great for me. However, I would also like to use another script that would follow French punctuation rules.
One-part punctuation marks:
These are similar in French and English
Two-part punctuation marks:
In French, a space is required both before and after all two- (or more) part punctuation marks and symbols, including : ; « » ! ? % $ # etc.
Note: The quotation marks (inverted commas) " " don't exist in French; the guillemets « » are used. I don't think that I will ever find a way to change something like "Hi, Jean!" into « Hi, Jean ! ». Anyway, that's another story.
I would be happy with the proper spaces. Here's the script I'm using for English punctuation. Could there be a quick fix to it?
Thanks,
Pierre
function TextTidy(VALUE){
var STRING = VALUE;
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}
var stri = " i ";
var strI = " I ";
while(STRING.indexOf(stri) > -1){
STRING = STRING.replace(stri,strI);
}
while(STRING.indexOf(" ") > -1){
STRING = STRING.replace(" "," ");
}
var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();
for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter);
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 46 || iChar == 33 || iChar == 63){
if(STRING.charCodeAt(iCounter+1)==32){
strReturn_Value += (STRING.substring(iCounter+1,iCounter+2)) + "";
iCounter+=1;
}
UcaseNext = true;
}
else if(iChar==13 && STRING.charCodeAt(iCounter+1)==10){
iCounter+=1;
//Comment out the next line if you want to stop capitalization on a new line
UcaseNext = true;
}
else if(iChar==44 && STRING.charCodeAt(iCounter+1)!=32){
strReturn_Value += (STRING.substring(iCounter,iCounter)) + " ";
}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}
}
return strReturn_Value;
} //End Function
http://fslactivities.sd61.bc.ca/ezHTMLarea/popups/plaintext.html
This works great for me. However, I would also like to use another script that would follow French punctuation rules.
One-part punctuation marks:
These are similar in French and English
Two-part punctuation marks:
In French, a space is required both before and after all two- (or more) part punctuation marks and symbols, including : ; « » ! ? % $ # etc.
Note: The quotation marks (inverted commas) " " don't exist in French; the guillemets « » are used. I don't think that I will ever find a way to change something like "Hi, Jean!" into « Hi, Jean ! ». Anyway, that's another story.
I would be happy with the proper spaces. Here's the script I'm using for English punctuation. Could there be a quick fix to it?
Thanks,
Pierre
function TextTidy(VALUE){
var STRING = VALUE;
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}
var stri = " i ";
var strI = " I ";
while(STRING.indexOf(stri) > -1){
STRING = STRING.replace(stri,strI);
}
while(STRING.indexOf(" ") > -1){
STRING = STRING.replace(" "," ");
}
var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();
for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter);
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 46 || iChar == 33 || iChar == 63){
if(STRING.charCodeAt(iCounter+1)==32){
strReturn_Value += (STRING.substring(iCounter+1,iCounter+2)) + "";
iCounter+=1;
}
UcaseNext = true;
}
else if(iChar==13 && STRING.charCodeAt(iCounter+1)==10){
iCounter+=1;
//Comment out the next line if you want to stop capitalization on a new line
UcaseNext = true;
}
else if(iChar==44 && STRING.charCodeAt(iCounter+1)!=32){
strReturn_Value += (STRING.substring(iCounter,iCounter)) + " ";
}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}
}
return strReturn_Value;
} //End Function