Repository: microsoft/PowerToys
File: src/modules/PowerOCR/PowerOCR/Helpers/ImageMethods.cs (C#)

Code before:
        await using (MemoryStream memory = new MemoryStream())
        {
            scaledBitmap.Save(memory, ImageFormat.Bmp);
            memory.Position = 0;
            BitmapDecoder bmpDecoder = await BitmapDecoder.CreateAsync(memory.AsRandomAccessStream());
            SoftwareBitmap softwareBmp = await bmpDecoder.GetSoftwareBitmapAsync();

            OcrEngine ocrEngine = OcrEngine.TryCreateFromLanguage(selectedLanguage);
            OcrResult ocrResult = await ocrEngine.RecognizeAsync(softwareBmp);

            if (singlePoint == null)
            {
                if (isCJKLang == false)
                {
                    foreach (OcrLine line in ocrResult.Lines)
                    {
                        text.AppendLine(line.Text);
                    }
                }
                else
                {
                    var cjkRegex = new Regex(@"\p{IsCJKUnifiedIdeographs}");

                    foreach (OcrLine ocrLine in ocrResult.Lines)
                    {
                        bool isBeginning = true;
                        bool isCJKPrev = false;
                        foreach (OcrWord ocrWord in ocrLine.Words)
                        {
                            bool isCJK = cjkRegex.IsMatch(ocrWord.Text);

                            if (isBeginning || (isCJK && isCJKPrev))
                            {
                                _ = text.Append(ocrWord.Text);
                            }
                            else
                            {
                                _ = text.Append(' ').Append(ocrWord.Text);
                            }

                            isCJKPrev = isCJK;
                            isBeginning = false;
                        }

                        text.Append(Environment.NewLine);
                    }
                }
            }
            else
            {
                Windows.Foundation.Point fPoint = new Windows.Foundation.Point(singlePoint.Value.X, singlePoint.Value.Y);

Review comment (suggestion):
I feel like the logic maybe could be tweaked?  Like, 
forloop
{
  if ! (isCJK && isCJKPrev)
     append space

  append word
  set isCJKPrev 
}
trim at the end of forloop

Code after:
        await using (MemoryStream memory = new MemoryStream())
        {
            scaledBitmap.Save(memory, ImageFormat.Bmp);
            memory.Position = 0;
            BitmapDecoder bmpDecoder = await BitmapDecoder.CreateAsync(memory.AsRandomAccessStream());
            SoftwareBitmap softwareBmp = await bmpDecoder.GetSoftwareBitmapAsync();

            OcrEngine ocrEngine = OcrEngine.TryCreateFromLanguage(selectedLanguage);
            OcrResult ocrResult = await ocrEngine.RecognizeAsync(softwareBmp);

            if (singlePoint == null)
            {
                if (isCJKLang == false)
                {
                    foreach (OcrLine line in ocrResult.Lines)
                    {
                        text.AppendLine(line.Text);
                    }
                }
                else
                {
                    var cjkRegex = new Regex(@"\p{IsCJKUnifiedIdeographs}");

                    foreach (OcrLine ocrLine in ocrResult.Lines)
                    {
                        bool isBeginning = true;
                        bool isCJKPrev = false;
                        foreach (OcrWord ocrWord in ocrLine.Words)
                        {
                            bool isCJK = cjkRegex.IsMatch(ocrWord.Text);

                            // Use spaces to separate non-CJK words.
                            if (!isBeginning && (!isCJK || !isCJKPrev))
                            {
                                _ = text.Append(' ');
                            }

                            _ = text.Append(ocrWord.Text);
                            isCJKPrev = isCJK;
                            isBeginning = false;
                        }

                        text.Append(Environment.NewLine);
                    }
                }
            }
            else
            {
                Windows.Foundation.Point fPoint = new Windows.Foundation.Point(singlePoint.Value.X, singlePoint.Value.Y);
                foreach (OcrLine ocrLine in ocrResult.Lines)
                {