filter ASCII characters v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 19 May 2020 17:04:22 +0200
branchv_0
changeset 2a84830179027
parent 1 6733bd832b61
child 3 51a8362261a9
filter ASCII characters
mt-32-display.cpp
     1.1 --- a/mt-32-display.cpp	Tue May 19 16:03:25 2020 +0200
     1.2 +++ b/mt-32-display.cpp	Tue May 19 17:04:22 2020 +0200
     1.3 @@ -28,8 +28,16 @@
     1.4   * If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
     1.5   * and then returns back to the default screen.
     1.6   * 
     1.7 - * Usage:
     1.8 + * Only printable ASCII characters are supported. Other characters (bytes) are replaced by "."
     1.9 + * 
    1.10 + * Some characters are displayed differently:
    1.11 + *   ASCII   MT-32
    1.12 + *       ~   →
    1.13 + *       \   ¥
    1.14 + * 
    1.15 + * Usage examples:
    1.16   *     amidi --port="hw:2,0,0" --send-hex="$(echo -n '   Run GNU/Linux    ' | ./mt-32-display )"
    1.17 + *     while read message; do amidi --port="hw:2,0,0" --send-hex="$(echo -n "$message" | ./mt-32-display )"; done
    1.18   * 
    1.19   * @param argc
    1.20   * @param argv
    1.21 @@ -47,6 +55,7 @@
    1.22  	sum += 0x00;
    1.23  
    1.24  	for (char ch; std::cin.read(&ch, 1).good();) {
    1.25 +		if (ch < 32 || ch > 126) ch = '.';
    1.26  		std::cout << std::setw(2) << ((int) ch) << " ";
    1.27  		sum += ch;
    1.28  	}