2

I'm having trouble using copy/paste from pgAdmin 4. The symptom is that I get the character <U+FEFF> aka Zero Width No-break Space aka Byte Order Mark (BOM) prepended to any string I copy.

The workaround is to paste and then delete that first character. But in practice this is cumbersome. In some contexts the character does not get pasted (in vim on my machine). In some contexts it is pasted, but it's not visible. In other cases it is "visible" as a space (in TextWrangler on my machine).

Here's a bit more detail. I successfully type and execute a query:

select 'this is constant text value in my query'

I select and copy these 4 characters: text

I think my clipboard should contain just those 4 characters. But it doesn't. Instead, it contains this: <U+FEFF>text

This is perhaps related to this old thread between Josh Berkus and Dave Page. But that discussion focuses on the fact that pgAdmin puts the character at the beginning of any file. In my case it's really not the file that is the issue. It's the clipboard.

More practically, the solution in that case was to go to File -> Options and turn off Unicode file writing. In pgAdmin 4 (v2.1 on MacOS), that menu doesn't exist. The menu File -> Preference exists, but I can find no corresponding setting in the Preferences.

Question: can anyone help me to prevent the FEFF character from sneaking into the clipboard whenever I copy anything in pgAdmin?

  • 2
    I guess this will hardly help you with the issue proper but as an explanation regarding the "should contain", the byte order mark is meant to go at the beginning of a text stream. I believe the clipboard can be viewed as a stream. Consequently, when it contains text, it's a text stream. The piece of text you are copying is stored as Unicode text properly marked with a BOM. – Andriy M Mar 7 '18 at 21:00
  • It looks like a bug report that should go to pgAdmin developers. Also please mention your operating system. – Daniel Vérité Mar 8 '18 at 14:11
  • @AndriyM you bring up an important point, but I think it's not 100% correct. The BOM is optional in UTF-8. If it's included, then it should not be 0xFE 0xFF (which would represent UTF-16 Big Endian) but rather 0xEF,0xBB,0xBF. So for these UTF-8 files (and streams) which are UTF-8, it's truly not valid. – mdahlman Mar 9 '18 at 17:00
  • Re: byte sequence – no, it's the same BOM in UTF-8. The byte sequence is different because that's how the BOM is encoded in UTF-8. It's the byte sequence that determines which Unicode encoding is used for the text that follows. For UTF-16LE, it's FF FE, for UTF-16BE, FE FF, and for UTF-8, EF BB BF. – Andriy M Mar 9 '18 at 18:12
  • Everything that you wrote is surely correct. What I was trying to say is that this is a UTF-8 file, and therefore pgAdmin should not be putting the byte sequence FE FF at the beginning because FE FF doesn't correspond to UTF-8. No? – mdahlman Mar 10 '18 at 0:18
1

It turns out this is a known bug:

https://redmine.postgresql.org/issues/2980

It has been fixed in source already. Expect the fix in pgAdmin 4 v3. Khushboo said in the pgadmin-support list that it will be out soon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.