diff options
author | Teravus Ovares | 2007-12-28 23:19:03 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-12-28 23:19:03 +0000 |
commit | 0631151e08174fffbc5bf3f646ef32e16e2c5145 (patch) | |
tree | cd5c03148d599fbe9c9929ff98b5894c5a4cdd43 /OpenSim/Framework/Util.cs | |
parent | Add System.Xml back into AssetServer and into AssetLoader for the first time.... (diff) | |
download | opensim-SC-0631151e08174fffbc5bf3f646ef32e16e2c5145.zip opensim-SC-0631151e08174fffbc5bf3f646ef32e16e2c5145.tar.gz opensim-SC-0631151e08174fffbc5bf3f646ef32e16e2c5145.tar.bz2 opensim-SC-0631151e08174fffbc5bf3f646ef32e16e2c5145.tar.xz |
* Patch from Melanie provides Util.CleanString and uses it on the prim name and description. Thanks Melanie.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e6512c2..08b3a9d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -222,10 +222,7 @@ namespace OpenSim.Framework | |||
222 | output.Append(": "); | 222 | output.Append(": "); |
223 | } | 223 | } |
224 | 224 | ||
225 | if (bytes[bytes.Length - 1] == 0x00) | 225 | output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1))); |
226 | output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1)); | ||
227 | else | ||
228 | output.Append(UTF8Encoding.UTF8.GetString(bytes)); | ||
229 | } | 226 | } |
230 | else | 227 | else |
231 | { | 228 | { |
@@ -406,5 +403,31 @@ namespace OpenSim.Framework | |||
406 | { | 403 | { |
407 | return lluuid.UUID.ToString("n"); | 404 | return lluuid.UUID.ToString("n"); |
408 | } | 405 | } |
406 | |||
407 | public static string CleanString(string input) | ||
408 | { | ||
409 | if(input.Length == 0) | ||
410 | return input; | ||
411 | |||
412 | int clip=input.Length; | ||
413 | |||
414 | // Test for ++ string terminator | ||
415 | int pos=input.IndexOf("\0"); | ||
416 | if(pos != -1 && pos < clip) | ||
417 | clip=pos; | ||
418 | |||
419 | // Test for CR | ||
420 | pos=input.IndexOf("\r"); | ||
421 | if(pos != -1 && pos < clip) | ||
422 | clip=pos; | ||
423 | |||
424 | // Test for LF | ||
425 | pos=input.IndexOf("\n"); | ||
426 | if(pos != -1 && pos < clip) | ||
427 | clip=pos; | ||
428 | |||
429 | // Truncate string before first end-of-line character found | ||
430 | return input.Substring(0, clip); | ||
431 | } | ||
409 | } | 432 | } |
410 | } \ No newline at end of file | 433 | } |