title: Replacement Character appearing in my colored output
body: <p>I've got a strange problem I can't seem to diagnose effectively. I wanted a simple tool that could take a BufferedImage and print it to a console for my class. In relpit, the console's font uses perfect 2-1 characters, so to print a pixel, you only need to print two spaces with a certain background color.</p>
  <p>This works well, but the pixels are bigger than they need to be. If you use a special character called an upper half-block, you can cut pixel size down from 2-2 to 1-1, quadrupling the density and rendering it easy to use.</p>
  <p>This is almost amazing, but a problem does show up (as it usually does when I open the character map). Sometimes the half-block does not print, and I am left with two replacement characters. This does not happen when coloring is absent or when I use Ascii characters instead, and to make it worse, the error is apparently random, with lighting only sometimes striking the same position twice.</p>
  <p>I tried to set this up in eclipse to see if I could see an improvement, but the console won't support this coloring method I know or even let me type the upper half block (I'm sure there's an escape sequence for it, but I'm not familiar).</p>
  <p>I'll summarize my approach here I'm using these for coloring:</p>
  <pre><code>private static String getRGBBackground(int r, int g, int b) {
      return &quot;\u001B[48;2;&quot; + r + &quot;;&quot; + g + &quot;;&quot; + b + &quot;m&quot;;
  }
  private static String getRGBForeground(int r, int g, int b) {
      return &quot;\u001B[38;2;&quot; + r + &quot;;&quot; + g + &quot;;&quot; + b + &quot;m&quot;;
  }
  </code></pre>
  <p>This is the print statement itself:</p>
  <pre><code>public void print (BufferedImage image) {
          StringBuilder str = new StringBuilder();
  
          for (int r = 0; r &lt; image.getHeight(); r+=2) {
              for (int c = 0; c &lt; image.getWidth(); c++) {
                  
                  int color = image.getRGB(c,r);
                  color &lt;&lt;= 8;
                  color &gt;&gt;&gt;= 8;
                  int blu = (color &gt;&gt;  0) % 256;
                  int grn = (color &gt;&gt;  8) % 256;
                  int red = (color &gt;&gt; 16) % 256;
                  
                  str.append(getRGBForeground(red,grn,blu));
  
                  if ((r+1) &lt; image.getHeight()) {
                      color = image.getRGB(c,r+1);
                      color &lt;&lt;= 8;
                      color &gt;&gt;&gt;= 8;
                      blu = (color &gt;&gt;  0) % 256;
                      grn = (color &gt;&gt;  8) % 256;
                      red = (color &gt;&gt; 16) % 256;
                      str.append(getRGBBackground(red,grn,blu));
                  }
  
                  str.append(&quot;▀&quot;);
              }
              str.append(&quot;\u001b[0m\n&quot;);
          }
  
          out.println(str);
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/AWRuZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AWRuZ.jpg" alt="Sample program output" /></a></p>
  <p>If anyone has any tips to address the replacement character or even just closer that these things don't ever work, that would be greatly appreciated!</p>