I have a PLpgSQL function that returns a string (varchar): if this string is over 256 characters long then the last three characters are corrupted: replaced by the string ' (.'
I'm skeptical: there is nothing special about 256 characters as far as the varchar implementation is concerned, nor is the string ' (.' of any significance.
Running your function (albeit on Linux) yields:
neilc=# select testconverttousername();
testconverttousername
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567888 (1 row)
i.e. what one would expect.
-Neil
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq