Emojis in Harbour

87 views
Skip to first unread message

Hbmclip

unread,
May 31, 2025, 9:05:31 AMMay 31
to Harbour Users
Hi all

Why Harbour doesn't show all UTF-8 characters ?

Bellow a Harbour program:

-------------------------
PROCEDURE Main
   LOCAL nRow := 1
   LOCAL aEmojis := { ;
      "😀", "😂", "😍", "😎", "🥳", ; // Faces
      "👍", "👏", "🙌", "✋", "👌", ; // Hands
      "❤️", "💖", "💎", "⭐", "🌟", ; // Symbols
      "🌍", "🌈", "☀️", "🌙", "⚡", ; // Nature
      "🍎", "🍕", "🍔", "☕", "🍷", ; // Food
      "🚗", "✈️", "🚀", "🚲", "🛸", ; // Transport
      "⚽", "🏀", "🎾", "🏈", "🎯"  ; // Sports
   }
   LOCAL nEmoji, nCol

   SET SCOREBOARD OFF
   // Set color to white on blue
   //SET COLOR TO "W/B"
   CLS

   // Loop through emojis to display in a grid
   FOR nEmoji := 1 TO Len(aEmojis)
      nCol := 2 + ((nEmoji - 1) % 5) * 5
      IF nEmoji % 5 == 1 .AND. nEmoji > 1
         nRow += 2
      ENDIF
      // Display emoji at specified row and column
      @ nRow, nCol SAY aEmojis[nEmoji]
   NEXT

   // Display exit message
   @ nRow + 2, 2 SAY "Press any key to exit..."
   Inkey(0)
RETURN
------------------
The same program in Python:

import os

def main():
    # List of UTF-8 emojis (same as the Harbour program)
    emojis = [
        "😀", "😂", "😍", "😎", "🥳",  # Faces
        "👍", "👏", "🙌", "✋", "👌",  # Hands
        "❤️", "💖", "💎", "⭐", "🌟",  # Symbols
        "🌍", "🌈", "☀️", "🌙", "⚡",  # Nature
        "🍎", "🍕", "🍔", "☕", "🍷",  # Food
        "🚗", "✈️", "🚀", "🚲", "🛸",  # Transport
        "⚽", "🏀", "🎾", "🏈", "🎯"   # Sports
    ]

    # Clear the screen (equivalent to CLS in Harbour)
    os.system('cls' if os.name == 'nt' else 'clear')

    row = 1
    # Loop through emojis to display in a grid
    for i, emoji in enumerate(emojis, 1):
        col = 2 + ((i - 1) % 5) * 5
        if i % 5 == 1 and i > 1:
            row += 2
        # Simulate @ row, col SAY with formatted print
        print(f"\033[{row};{col}H{emoji}", end="")
   
    # Display exit message
    print(f"\033[{row + 2};2HPress Enter to exit...")
    input()

if __name__ == "__main__":
    main()


---------------------------------

Python works fine, but Harbour doesn't display some characters

Thx all

Reply all
Reply to author
Forward
0 new messages