views:

43

answers:

1

Say, I have a script nicely formatted in SSMS and it's annotated with all kinds of comments in different languages. But when I copy and paste this nice thingy into Word with syntax highlighted I will get a syntax-highlighted message with those comments garbled, as if reading the source text with one code page and pasting it using another code page. Very nasty kinda bug. Does anyone know how to solve this issue once and for all?

Thank you!

[Update]

alt text

[Solution]

Save → Save with Encoding... → Encoding : Unicode (UTF-8 with signature).

[Related forums]

+1  A: 

After some tests, I'm still unable to reproduce the issue. And I have no idea why copy-pasting text from one Unicode-compatible to another Unicode-compatible app can give such results.

There are several things you can try:

  1. Inside SSMS, save the script as an Unicode file: SaveSave with Encoding...Encoding : Unicode (UTF-8 with signature). You will then be able to open it probably correctly in Word. The problem is that syntax highlighting will be lost.

  2. Save the script as an Unicode file, than reopen it and copy-paste. Maybe SSMS assume for some reasons that there is some fancy encoding by default, so this will force it to use UTF-8 instead.

  3. Try to paste in different applications (for example the browser). Looking at the first line at your screenshot, I remember once seeing the same problem with some browser renderings described on Wikipedia (can't find the link).

  4. Try copying the same text from Visual Studio (if installed). Copying source code from Visual Studio to Office programs preserve syntax highlighting, so if you observe the same issue, it may come from this syntax highlighting feature.

  5. If nothing works, report the problem to Microsoft Connect, describing precisely the situation so the people at Microsoft will be able to reproduce this issue.

MainMa
Thank you, I will give it a shot.
Denis Valeev
Save → Save with Encoding... → Encoding : Unicode (UTF-8 with signature). Solved the copy-paste problem! But there's no way to make it the default option. So, it's a good candidate for a Microsoft Connect issue now.
Denis Valeev