Skip to content

Commit bf4490e

Browse files
committed
Set process output encoding to UTF-8
This enables full unicode in commit change log too.
1 parent e7c3a2c commit bf4490e

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

src/File/GitHub.cs

+1-32
Original file line numberDiff line numberDiff line change
@@ -270,40 +270,9 @@ commitJson is JObject commitObj &&
270270
output.AppendLine($"# {group.Key}").AppendLine();
271271
ColorConsole.WriteLine($"# {group.Key}".Gray());
272272

273-
// GitHub REST API does not seem to handle unicode the same way the website
274-
// does. Unicode emoji shows up perfectly fine on the web (see https://github.com/devlooped/oss/commits/main/.github/workflows/build.yml)
275-
// yet each emoji shows up as multiple separate chars in the responses. We
276-
// implement a simple cleanup that works in our tests with devlooped/oss repo.
277-
static string removeUnicodeEmoji(string message)
278-
{
279-
var result = new StringBuilder(message.Length);
280-
var index = 0;
281-
while (index < message.Length)
282-
{
283-
// Consider up to U+036F / 879 char as "regular" text.
284-
// This would allow some formatting chars still.
285-
// Anything higher, consider as the start of an unicode emoji
286-
// symbol comprising more chars until the next high one.
287-
if (message[index] > 879)
288-
{
289-
while (++index <= message.Length && message[index] <= 879 && !char.IsWhiteSpace(message[index]))
290-
;
291-
292-
index++;
293-
}
294-
else
295-
{
296-
result.Append(message[index]);
297-
index++;
298-
}
299-
}
300-
301-
return result.ToString();
302-
};
303-
304273
foreach (var (sha, date, message) in commits)
305274
{
306-
var line = $"- {removeUnicodeEmoji(message).Trim()} https://github.com/{group.Key}/commit/{sha[..7]}";
275+
var line = $"- {message.Trim()} https://github.com/{group.Key}/commit/{sha[..7]}";
307276
output.AppendLine(line);
308277
ColorConsole.WriteLine(line.Gray());
309278
}

src/File/Process.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public static bool TryExecute(string program, string arguments, out string outpu
1010
var info = new ProcessStartInfo(program, arguments)
1111
{
1212
RedirectStandardOutput = true,
13-
RedirectStandardError = true
13+
RedirectStandardError = true,
14+
StandardOutputEncoding = System.Text.Encoding.UTF8,
1415
};
1516

1617
try

0 commit comments

Comments
 (0)