views:

293

answers:

3

Has anyone got a function to convert convert curly quotes and em dashes into " and -?

I've tried writing one but it fails when copying stuff from MS word into a textarea.

Thanks

+4  A: 

str_replace()?

code_burgar
A: 

You sure it's an em-dash and not a quotation-dash or a en-dash. Perhaps that's why (you think) it fails.

Bart Kiers
A: 

oh ms word... in vim I do the following to convert all the funky characters word makes up into normal ascii characters:

:%s/<C-V>226<C-V>128[<C-V>173<C-V>172]//geI<Return>:%s/<C-V>226<C-V>128[<C-V>157<C-V>156]/"/geI<Return>:%s/<C-V>226<C-V>128<C-V>153/'/geI<Return>:%s/<C-V>146/'/geI<Return>:%s/<C-V>150/-/geI<Return>:%s/<C-V>147/"/geI<Return>:%s/<C-V>148/"/geI<Return>:%s/<C-V>133/.../geI<Return>:%s/<C-V>171/<</geI<Return>:%s/<C-V>226<C-V>128<C-V>166/.../geI<Return>:%s/<C-V>226<C-V>128"/--/geI<Return>:%s/<C-V>226<C-V>128<C-V>162/<C-V>183/geI<Return>:%s/<C-V>195<C-V>168/<C-V>232/geI<Return>:%s/<C-V>195<C-V>180/<C-V>244/geI<Return>:%s/<C-V>187/>>/geI<Return>:%s/<C-V>194//geI<Return>:%s/<C-V>195<C-V>162/<C-V>226/geI<Return>:%s/<C-V>195<C-V>170/<C-V>234/geI<Return>:%s/<C-V>195<C-V>174/<C-V>238/geI<Return>:%s/<C-V>195<C-V>169/<C-V>233/geI<Return>:%s/<C-V>195<C-V>167/<C-V>231/geI<Return>:%s/<C-V>195<C-V>160/<C-V>224/geI<Return>:%s/<C-V>160/ /geI<Return>:%s/<C-V>197"/\&oelig;/geI<Return>:%s/<C-V>239<C-V>172<C-V>129/fi/geI<Return>:%s/<C-V>239<C-V>172<C-V>130/fl/geI<Return>:%s/<C-V>226<C-V>128<C-V>152/'/geI<Return>:%s/<C-V>226<C-V>128<C-V>168//geI<Return>:%s/<C-V>239<C-V>172<C-V>131/ffi/geI<Return>:%s/<C-V>239<C-V>172<C-V>128/ff/geI<Return>:%s/<C-V>239<C-V>172<C-V>132/ffl/geI<Return>:%s/<C-V>195<C-V>175/<C-V>239/geI<Return>

A few of those are for funky characters I get from converting pdf to text, but mostly from word.

Best of luck...

Basically you need to figure out what bytes/characters word is pasting (use a hex editor or something) and use str_replace or preg_replace with those bytes/characters.

JasonWoof