|
|
|
@ -941,7 +941,11 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -941,7 +941,11 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
return ConvertChar(ch); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static string ConvertChar(char ch) |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the escape sequence for the specified character.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>This method does not convert ' or ".</remarks>
|
|
|
|
|
public static string ConvertChar(char ch) |
|
|
|
|
{ |
|
|
|
|
switch (ch) { |
|
|
|
|
case '\\': |
|
|
|
@ -963,7 +967,9 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -963,7 +967,9 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
case '\v': |
|
|
|
|
return "\\v"; |
|
|
|
|
default: |
|
|
|
|
if (char.IsControl(ch) || char.IsSurrogate(ch)) { |
|
|
|
|
if (char.IsControl(ch) || char.IsSurrogate(ch) || |
|
|
|
|
// print all uncommon white spaces as numbers
|
|
|
|
|
(char.IsWhiteSpace(ch) && ch != ' ')) { |
|
|
|
|
return "\\u" + ((int)ch).ToString("x4"); |
|
|
|
|
} else { |
|
|
|
|
return ch.ToString(); |
|
|
|
@ -971,7 +977,10 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -971,7 +977,10 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static string ConvertString(string str) |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts special characters to escape sequences within the given string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string ConvertString(string str) |
|
|
|
|
{ |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
foreach (char ch in str) { |
|
|
|
@ -2145,7 +2154,9 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -2145,7 +2154,9 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
// "1.0 / /*comment*/a", then we need to insert a space in front of the comment.
|
|
|
|
|
formatter.Space(); |
|
|
|
|
} |
|
|
|
|
formatter.StartNode(comment); |
|
|
|
|
formatter.WriteComment(comment.CommentType, comment.Content); |
|
|
|
|
formatter.EndNode(comment); |
|
|
|
|
lastWritten = LastWritten.Whitespace; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|