Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some characters not showing up, but showing up as replacement character(Black diamond with question mark) #230793

Closed
nyhryan opened this issue Oct 8, 2024 · 3 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@nyhryan
Copy link

nyhryan commented Oct 8, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.94.0
  • OS Version: Windows NT x64 10.0.19045 (Windows 10 Korean, 22H2)

Steps to Reproduce:

// Filename : Korean.java
import java.util.Scanner;

public class Korean {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String word = scanner.next();
        System.out.println("입력한 단어: " + word);
        scanner.close();
    }
}

I have simple Java program that prints Korean message and a word the user typed.
image
image

What I tried:

  • With Windows Terminal app
    • with pwsh.exe : chcp 65001 && java Korean.java and type anything, will print properly.
    • with cmd.exe: chcp 65001 && java Korean.java and type anything. will print properly.
  • In VS Code's integrated terminal
    • either powershell or cmd: chcp 65001 && java Korean.java and type anything, will not print properly.
    • even tested with all extensions disabled

I am not sure if this is Java's problem or VS code's problem since I have no idea how to test this in more general situation.

@nyhryan
Copy link
Author

nyhryan commented Oct 8, 2024

import java.io.UnsupportedEncodingException;
import java.util.Scanner;

public class Korean {
    private static void printBytes(byte[] str) {
        StringBuffer sb = new StringBuffer();
        for (byte s: str) {
            sb.append(String.format("\\x%02x ", s));
        }
        System.out.println(sb);
    }
    
    private static void printCodepoints(String str) {
        for (int i = 0; i < str.length(); i++) {
            System.out.printf("U+%04X ", str.codePointAt(i));
        }
        System.out.println();
    }

    public static void main(String[] args) throws UnsupportedEncodingException {
        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        System.out.printf("String: %s\n", str);

        byte[] bytes = str.getBytes("UTF-8");
        printBytes(bytes);
        printCodepoints(str);

        sc.close();
    }
}

I have added some methods to print out bytes in hex and unicode code points.

image

I tried to print byte values and unicode code points of my input. here are comparison between windows terminal app and vs code. Above is Powershell in Windows terminall app, below is VS code's integrated terminal with Powershell.

@Tyriar
Copy link
Member

Tyriar commented Oct 8, 2024

If you use "terminal.integrated.experimental.windowsUseConptyDll": true this will probably fix your issue. There is a known issue with that setting where something an OpenConsole.exe process will hang around that you need to go kill in process manager. That's tracked in #225719 and #224488

@Tyriar Tyriar closed this as completed Oct 8, 2024
@Tyriar Tyriar added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 8, 2024
@nyhryan
Copy link
Author

nyhryan commented Oct 8, 2024

Oh thank you! This whole conpty stuff is bit complex haha

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

2 participants