Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72776

QKeyEvent key() only returns value of first surrogate for characters in Supplementary Planes

    XMLWordPrintable

Details

    • Linux/X11
    • 9ef69efb3bde086b593787efdda5ebd8f3544768 (qt/qtbase/dev) 2593479928ee2c348d2e830d93a5ee82d9b1d1e5 (qt/qtbase/6.2) 25fbb2173689838b4f62a2f2130bb4a8f1c0029e (qt/tqtc-qtbase/5.15)

    Description

      Consider a simple program which logs all keyPressEvent it receives:

      #include<iostream>
      #include<QApplication>
      #include<QWidget>
      #include<QKeyEvent>
      
      struct App:QWidget{
      	void keyPressEvent(QKeyEvent* event){
      		std::cout<<"key 0x"<<std::hex<<event->key()<<", text ";
      		char prev='[';
      		for(QChar& c:event->text()){
      			std::cout<<prev<<"0x"<<c.unicode();
      			prev=' ';
      		}
      		if(prev=='[')std::cout<<'[';
      		std::cout<<"]\n";
      	}
      };
      
      int main(int argc,char** argv){
      	QApplication app(argc,argv);
      	App ex;
      	ex.show();
      	return app.exec();
      }
      

      When this command is executed

      xdotool type --window 87654321 --clearmodifiers $(printf '\U0001f3fc')
      

      (with --window value set appropriately) the logged information is

      key 0xd83c, text [0xd83c 0xdffc]
      

      The expected value of key should be 0x1f3fc which is the Unicode codepoint of the character.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-72776
          # Subject Branch Project Status CR V

          Activity

            People

              paeglis Gatis Paeglis
              a918 a918 _
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes