Skip to content
Thoughtful, detailed coverage of everything Apple for 34 years
and the TidBITS Content Network for Apple professionals
39 comments

Beware When Pasting Phone Numbers Copied from Contacts

Have you ever had trouble pasting a phone number copied from Contacts into a Web form? It may not be a common problem, but it’s one that TidBITS reader Dave Fultz solved after a frustrating tussle with an online order form. 

Dave was trying to order a package in France, and the form requested a mobile number at the delivery address. To ensure he had it right, he copied it from Contacts and pasted it into the form, but when he clicked Submit, the form failed verification. He tried different formats for the phone number—in France, the leading zero in the ten-digit number should be included when calling inside the country but omitted when calling from abroad—to no effect. Pasting the number into a few online verification services failed as well. Nor did pasting as plain text make any difference.

So Dave texted his friend at the number, which worked fine, and asked her to send him the number exactly as she would give it to a French person. It looked the same as his version, but when he copied and pasted the number from the Messages thread, the form accepted it! What was going on?

Dave was planning to use a Python script in Terminal to compare the number he had from Contacts with the one his friend had sent, but when he pasted his number into Terminal, the problem revealed itself instantly, as you can see in the highlighted text in my test below, which shows extra characters on either side of the phone number.

Demonstration of the Unicode characters in Terminal

It turns out that Contacts on the Mac encloses all phone numbers in two zero-width (and thus invisible) Unicode characters: U+202D (LEFT-TO-RIGHT OVERRIDE) and U+202C (POP DIRECTIONAL FORMATTING). Dave speculated that those characters exempt the phone number from the surrounding text flow direction, which would be right-to-left with Hebrew and Arabic, for instance.

Contacts appears to store those characters with the phone number, but since they’re zero-width, there’s no way to avoid selecting them that I was able to find. I don’t believe Contacts is adding those characters to the numbers as part of the copy because if you select a few characters in the middle of a number and then copy and paste them into Terminal, the invisible characters won’t be present. They’re also unique to the phone number fields; a number stored in the Notes field won’t have them either. Finally, the issue is limited to Contacts on the Mac; the problem doesn’t afflict phone numbers copied from an iPhone or iPad in my testing. (Some subsequent research turned up an Ask Different thread that describes the problem—which has been reported to Apple as a bug—and confirms that it still exists in macOS 13.1 Ventura.)

Why don’t these characters cause more problems? When developers design apps that accept data, they generally create input filters that filter out unwanted data. A phone number field has no reason to accept invisible punctuation characters, so it’s good programming practice to drop them. If nothing else, filtering user input is an essential security practice because attackers will often try to feed a system data to inject malicious code or to cause buffer overflows that could be exploited.

So while it seems weird that Apple designed Contacts to enclose every phone number in those zero-width characters, it does protect phone numbers pasted into right-to-left text flows from being changed. It doesn’t seem necessary for Contacts to do this for all Mac users, however. Apple could try to identify when it would make sense—perhaps only when the user has enabled a right-to-left language in macOS’s Language & Region settings.

Hebrew and Arabic in the Language & Region preference pane

Practically speaking, if you run into a situation where a phone number copied and pasted from Contacts doesn’t work as expected, the simplest fix is to type the number by hand. You could also paste it into Terminal and copy just the phone number again, avoiding the extra Unicode characters on either side. 

If you regularly ran into this problem and wanted to rack up some geek points, you could create a Keyboard Maestro macro that automatically stripped those extra characters. Peeved by the need to retype numbers like an animal, Dave Fultz did exactly that, so you could use his macro as a starting point for whatever workflow makes sense to you.

Or you could do what I do and rely instead on the contact management app Cardhop, which doesn’t suffer from the problem and is far more pleasant to use (see “Cardhop Puts Contacts Front and Center,” 18 October 2017, and  “Cardhop 2.0 Bundled with Fantastical in Flexibits Premium,” 27 May 2021).

Subscribe today so you don’t miss any TidBITS articles!

Every week you’ll get tech tips, in-depth reviews, and insightful news analysis for discerning Apple users. For over 33 years, we’ve published professional, member-supported tech journalism that makes you smarter.

Registration confirmation will be emailed to you.

This site is protected by reCAPTCHA. The Google Privacy Policy and Terms of Service apply.

Comments About Beware When Pasting Phone Numbers Copied from Contacts

Notable Replies

  1. I so wish I had read this a couple hours ago. I literally just had this problem, and ended up typing my numbers all in manually, because every pasted number failed. At the time, I thought it was just an extra space I missed seeing or maybe a wrong hyphen (minus character instead). In any case, it’s good to know this going forward! Thanks for explaining this.

  2. Unfortunately, Apple is in a no-win situation here.

    If they just copy the text, then people trying to paste the number into a block of right-to-left text will end up with display problems

    If a phone number was just numbers (e.g. 5551234567), then it wouldn’t be a problem. Numbers are “weak” characters in Unicode, meaning they will always render in their correct direction (left-to-right) for European numbers, but will not change the direction of the surrounding text. Similarly, hyphens are weak characters, so “555-123-4567” would also render correctly.

    But spaces, for example, are “neutral” characters. They operate based on the direction of the surrounding text. So a phone number consisting of “555 123 4567”, when pasted into right-to-left text would be presented as “4567 123 555”. Each sequence of weak characters (the digits) is left-to-right, but the neutral space characters presents each block of digits as right-to-left when they are in a block of right-to-left text.

    There are additional, even more complicated rules when there are matched-bracket-pairs (e.g. parentheses) in the text.

    The only way to avoid this mess when pasting phone numbers (which may have a virtually infinite mix of weak characters, neutral characters and bracket-pairs) into right-to-left text is to use the left-to-right override, to ensure that the entire sequence will always be presented as left-to-right text.

    So Apple must choose between breaking web forms (where the web designer really should be filtering out these characters anyway) or breaking the ability to paste into some documents, which will probably result in just as many problems and would probably require the same solution (to manually re-type the number).

  3. But wouldn’t the suggestion of having this happen only when the user has RTL languages enabled on the Mac resolve it? It feels like the sort of thing that doesn’t need to be the same for everyone.

  4. Enabled in what way? To simply have the fonts installed? To have a keyboard configured? To be running macOS’s UI in that language? What about the ability to enable languages on a per-app basis?

    For example, I can view and edit a Japanese document, even though I don’t have the language installed. I can’t type the characters without adding the keyboard and input method, but I can copy/paste text in both directions without them.

    In general, this is a pretty complicated issue.

    This might be solvable via the clipboard - include the characters for Unicode text, but strip them from Plain text content. And it might even do that already. But then you still need the web browser to use the plain-text version when pasting into forms. Which could be a problem for other fields (e.g. a name or address, where international characters may be required).

    I think ultimately, browsers may need to add a “paste special” command, or some equivalent. I know that when I use Microsoft Outlook on my Windows PC, the editor is a subset of the Microsoft Word editor. I can type Ctrl-V to paste formatted text, but Ctrl-Shift-V to paste the text without formatting. Something like that in a web browser for entering text in forms might be a workaround, but only if users actually try it.

  5. Heck, phone numbers are even hard to enter manually in many web forms. The designer tries to outsmart users by automatically adding (or not) hyphens and parentheses, and so on. It’s almost as frustrating as entering two-letter abbreviations for States. (And, as Adam noted, a pox on those programmers who don’t use a strip() function to remove starting and trailing spaces.)

  6. I’ve been thinking about this further and David C. is correct this is not a simple problem.

    Paste as Plain Text doesn’t work because you may want to paste plain, unstyled phone numbers into Hebrew Text.

    My spiffy little Keyboard Maestro macro doesn’t work because most people don’t have KM and won’t remember the problem well enough to find the macro in the menu and they really won’t remember it when they’re so frustrated they can’t buy that present for Aunt Marge instantly.

    What occurs to me is to make the characters visible in Contacts and in web forms. It’s yet another layer of display logic to program (show kinky doodad when encountering U+202C, etc. and replace with original when copying) but by having it visible and the phone number fails validation the average user will then say, “What’re those strange things? I’ll just copy the number itself…” You could do all sorts of nifty & weird stuff like making things like leading and trailing whitespace obvious. :sunglasses:

    Apple designers would be horrified at this desecration of visual simplicity but you know? Sometimes simplicity means being obvious.

    Trust me, I have written hundreds of regular expressions to recognize international phone numbers in text flows and the variety is boggling. Better to give the user a simple way to make sure Aunt Marge’s proper phone number gets into that order form.

    :slight_smile:

    Dave

  7. So it’s not a problem that Contacts is the only place in the UI where you can’t select some displayed text, do a standard Copy, and not be able to do a standard Paste of the same displayed text elsewhere?

    If the user doesn’t see these invisible markers, he definitely doesn’t want to copy them with the text. This is a “gotcha” for most users that doesn’t “just work.”

  8. I’m with @schwartz - I want nothing added to that field that I didn’t type in the first place when I created the contact. In fact, if Apple is going to be smart about it, I’d just want them to strip out any white space and paste in everything else. If it causes too many characters to be pasted in, I’ll deal with it manually and curse the web form designer.

  9. Digression.

    I would phrase it as the designer frustrates the user by assuming that the user will know what format the designer uses and therefore there is no need to state what format the form expects. It cannot be that hard to state what format to use. And when a form wants a Social Security number or a phone number spread over three fields, it seems to me that the insertion point should move to the next field rather than requiring tab. And I have come across forms that require a click because they do not accept tab.

  10. No extra characters for me, on Big Sur. Maybe a Monterey or Ventura problem?

  11. No extra characters for me in Ventura. I copied several telephone numbers, pasted them in BBEdit and no extraneous character was found.
    Francisco

  12. On my systems (one running Sierra, one Big Sur), I have found that some contacts include these symbols and some do not. And (problematically, IMO), some don’t include the terminating pop-directional-formatting character. And the left-to-right-override isn’t always the first character. (e.g. when my number begins with a +1 , the override appears between the +1 and the area code.)

    So it may not be the contacts app itself, but a function of what app was used to create the contacts. Mine come from iCloud and my Google contacts, and both sets have contacts added through a variety of mechanisms over the years, including:

    • Entered via the Contacts app (and Address Book before that) on all versions of Mac OS since the app was invented (and before there was an iCloud).
    • Entered via Google’s web interface for its contacts
    • Entered via various mail apps that offer integration with contacts apps (whether the Mac API or via LDAP/CardDav) on Mac, Windows and Linux systems
    • Entered via mobile contacts app on both iOS and Android
    • Imported via vCard objects and all kinds of apps and web sites

    Unfortunately, it is pretty much impossible for me to remember how I created all those contacts after over 20 years.

  13. I just had this type of oddity a few days ago when trying to paste a phone number from Contacts into a new email. I then tried pasting the number back into Contacts over the old number, and it inserted odd spaces in inappropriate places. The only way to repair the damage was to delete the original phone number entry, create a new one, and manually type the number back.

    But what occurs to me is the “original” number that was (invisibly) incorrectly formatted in Contacts was placed there as a copy and paste from a received Apple Mail email. It was part of a (business) Signature of that email. Maybe this is a common cause for this issue?

    I just submit this as a data point for possible consideration by others who have encountered this bug.

  14. Francisco,

    BBEdit doesn’t show those characters in a regular text window (even with Show Invisibles turned on). If you do a Hex Dump of the file you’ll see them.

    Really the best way to check is to paste the phone number into a Terminal window.

    Dave

  15. I used to do a lot of international calling, and this is not an exaggeration. To make it worse, the way phone numbers are written on web sites or in emails typically does not include codes for international calling, so you have to know how to make international calls from whatever country you are in. Add another layer of complication if you’re using a calling card which has its own codes. And just to complicate things further, small countries may not have ten-digit standards for phone numbers. If you’re trying to pick up numbers from caller IDs, some phone systems here in the US do not include the area code in calls within the same area code, and show only the last seven digits.

    With such divergent standards, the more you try to automate in processing, the more things are going to go wrong. When I try to return a call from within my area code by using automatic call-back, it doesn’t work if the caller ID gives only 7 digits because the phones expect the full 10 digits.

  16. fahirsch,
    Suggest NOT to include your e-mail address or phone number (what ever format +/- extra characters) here or any forum. Bots will find it, copy it, try to link it to your name, and sell it. Suggest to edit your post and remove it as soon as possible.
    Just sayin’

  17. I use several mail addresses, including one one for sites that are almost guaranteed I will get spam. Incredible as it may seem, at this address, which I have been using for 12 years, and only use for some mail lists, I have never received a single spam mail (hope tomorrow it won’t start).
    But I will do as you sugest.

    Francisco

  18. If you use the Text → “Zap Gremlins…” → Replace with code → Use ASCII equivalent

    they will show up .

  19. One of the recommendations in the article is to use the App, Cardhop. I checked into it but could not find pricing information from links on their website, and had to do a browser search to find it. Prices are only provided on a monthly basis for both monthly and yearly pricing. I regard this as a psychological trick to make the cost seem low rather than to provide the actual yearly cost with an annual subscription. So here is the information:

    While Cardhop is free, the focus of the provider is to integrate it with another App, Fantastical a time management App of which is subscription software for at least $40/year for life. As for me, I am strongly opposed to ANY subscription software that stores my personal data given the fact that if I do not continue to pay I could be blocked from accessing my own data. Doing the math, if you use Fantastical, for 10 years that is at least $400, or more if they raise their prices. Not only that, if the company shuts down or drops the product, how are you going to access your data to transfer, it to another App? While the information is somewhat sketchy it seems that Fantastical will only sync with Apple Apps when the information is also stored on iCloud or some other cloud service such as Google. If you have local calendars on your Mac or perhaps reminders and notes, they seemingly will not be synced, Of course, this means that if your internet connection is down or unavailable your information will not be synced and it also raises privacy and security issues as these days, anything on the cloud can possibly be hacked or open to 3rd party scrutiny. despite providing promising to keep it safe and private. The good news about this is that Fantastical does allow exporting of information into ics, vcf or csv formats appropriately. For me, this would mean having to backup the data on a regular basis by exporting it. For me, the lack of local syncing on my Mac is a big showstopper.

  20. For years I have used TexEdit (set for plain text format) as a convenient filter to remove extraneous junk before pasting data, especially data from web pages. The total UI interaction for ‘paste special’ in Excel is longer and more complex than using TextEdit. I often keep a document window open just for this use.

    Today, I checked out the Terminal app for hidden character display. It shows that TextEdit works for removing these.

    I am disappointed at how many expensive web sites do not filter inputs – except for password entry which result in rules displayed only after a trial entry. It seems that quality checks on these sites consist of appearance checks by the marketing department without functional checks with real web browsers.

  21. US federal and Michigan state income tax forms differ on Social Security number entry. In other sites, mm/dd/yyyy date entry are sometimes one input field and others are three fields. Programmers are often lazy. :melting_face:

  22. There’s nothing new or hidden about Cardhop being free, with additional features available with a subscription. It’s bundled with Fantastical (which is a calendar app, not a CRM), on macOS, iOS, and iPadOS, as we covered in the article I linked at the end, and as Flexibits makes clear on its pricing page:

    If you don’t want to subscribe to a free app to get additional features, that’s your prerogative, but given that you have no experience with Cardhop or Fantastical, it comes off as mean-spirited to speak so negatively of them.

    I do use and recommend both Cardhop and Fantastical, which sync well with the system-wide contacts and calendar and to-do databases used by Contacts and Calendar and Reminders. Even ignoring the fact that both apps can be used for free, because they tie into Apple’s system-wide databases, there’s absolutely no lock-in.

    I honestly don’t know what the situation with local calendars or contact sets is, but since I want to access my data on all my devices and share with other people, I would never use them or recommend that others do. Most people use iCloud, Outlook, Google, or other calendaring and contact servers. If you want to keep everything local, don’t use Cardhop and Fantastical.

    The concern about the user’s Internet connection being down is a complete red herring. All calendar and contact data is stored locally, with changes being synced. If you don’t have Internet access for a while due to being on a flight or whatever, you just won’t get changes. As soon as you have Internet access again, everything catches up. And again, the same will be true of Apple’s Calendar and Contacts and Reminders.

    Finally, there are no significant security and privacy issues with Cardhop and Fantastical that aren’t shared by all other calendar and contact management apps that rely on online servers, including Apple’s apps. You can worry about it all you want, but I can’t recall ever seeing a significant breach of such services.

  23. Thank you. Perhaps calling it a CRM was a bit broad. I could only find the pricing page with a browser search as I could not find a like to it from the companies home page after searching for a link to it from the CardHop marketing page nor was actual pricing mentioned in the App Store. It felt to me that they were trying to hide it. I just did another check on the App Store for Fantastical and found it but it does not indicate that it is a subscription. However it does indicate a subscription for Flexibits under Cardhop on the App Store. Missed it on the first check as it was not obvious. As such I have just edited my comment to reflect all this new information to insure its accuracy.

  24. Thanks for this heads-up. I wonder if it is a similar problem to another that I have suffered recently when auto-filling credit card details into some websites. Usually, it works brilliantly but I have had it fail occasionally. Manually typing in the details works perfectly…

    Whilst we are talking about the Contacts app on Mac, I have to quit and restart this app more than any other. When creating a new contact, it either tries to edit an existing one or crashes halfway through the data entry. This is true on my Mac Studio and M2 Macbook Air, both of which had completely clean installs to try and solve this issue, but it persists. How can such a relatively simple but essential app be so troublesome? This problem has existed for several years. Sorry to hijack the thread – feel free to move this comment to a new thread, Adam. Merry Christmas, one and all!

  25. Interesting! Auto-filling from what app? Or do you mean in Safari?

  26. Been there, tripped over that.

    Solved it by pasting the contents of the copy buffer into a hex editor, which revealed the invisible and troublesome characters.

  27. Sorry Adam, yes I did mean in Safari using the AutoFill credit card details option in Preferences, sorry Settings!

  28. What happens if instead of Paste you use Paste And Match Style? If the web form field only accepts plain text, that is what should be pasted in. If the web form field is set to receive input in some special format, such at left-to-right, will those formatting characters be properly interpreted and the text entered correctly?

  29. It makes no difference—the Unicode characters are real characters, not formatting.

  30. I wonder if this has the same root cause that has been plaguing me with crashes in Contacts for years? Select a card - you don’t even have to go into edit mode. If your card is a member of any groups (manually created or smart), then pressing the ⌥ [option] key should normally highlight those groups in the side bar. My manually created groups are synched from my desktop Mac to my iPhone, my iPad and the old Mac at my old Mum’s home. However, the smart groups live just on my desktop Mac - and a handful of those groups are corrupt. When Contacts tries to access one of them to see if it should highlight the group, or if you simply click one of the groups to see the full list of contacts, it crashes Contacts.

    If you have any degree of muscle memory developed over the years, you could often be using the [option] key without thinking about it - and triggering the crash.

    In my case, when I finally get around to it (this only tends to be a problem at Christmas time when I’m writing Christmas cards and using the Notes fields to record it), I guess I’ll be deselecting Contacts under iCloud in System Preferences, so it’s not longer synched; locating and deleting the remaining locally stored copies; then reselecting Contacts in iCloud to resynch the cards themselves along with the manually configured groups (and then manually (re)create some of the smart groups from scratch).

  31. Hi GaryS,

    Many thanks for taking the trouble to reply on Christmas Day!

    I think you could be on to something here. I frequently encounter another bug with Contacts whereby if it has been open for more than a few minutes and I try to drag a contact into a group that it isn’t already in, the group doesn’t highlight and the procedure cannot be performed. If I quit and restart the app, it works correctly but the bug soon returns (I suspect when the app goes into the background).

    However, I am experiencing exactly the same issues on both my Mac Studio and M2 MacBook Air, so if there is a problem with my data, it is being stored in iCloud and with 2,184 cards, I don’t feel like starting again!

  32. This has bothered me for years… so frustrating. My solution: cmd-V, right arrow, backspace, up-arrow, forward-delete. I have to do it often enough that my fingers just do it, but not often enough that I’ve entrusted it to Keyboard Maestro.

  33. Exactly the same here. I do the same finger acrobatic almost automatically since many years and always think, «when will Apple solve this bug?». But as I read above, it is not necessarily a bug but a feature or something in-between :sweat_smile:

  34. Ray

    Maybe this is a problem with Cut and Paste of numbers into web forms on iOS. I just noticed this twice this week where a Copy and Paste of a number was not registered as a valid entry (the Continue button did not get dark) but me typing the number from my keyboard works.

    In my work I have to copy a 6 digit number from Symantec VIP and paste it into a web form pretty regularly. Is there a program/keyboard whatever for iOS that will execute a script or clean up my numbers for me?

  35. When I have encountered this, it is almost always a dimwitted web “developer” who is trying to use Javascript to validate input while the user types. A bad idea on so many levels…

    There are workarounds. Keyboard Maestro, for example, has an “Insert text by typing” command that can use the clipboard as its source and simulates typing instead of pasting.

  36. Ray

    I have KM, but I really need something that does the same thing with iOS so I can use it with my iPad.

  37. I have experienced this issue in a number of different scenarios on different websites. Copying and pasting email addresses, passwords, phone numbers etc simply does not work occasionally, for some reason, but typing in exactly the same info does. It is almost as if the website is prohibiting you from copying and pasting for security reasons but doesn’t actually go to the trouble of stopping it from working altogether.

Join the discussion in the TidBITS Discourse forum

Participants

Avatar for ace Avatar for Fahirsch Avatar for ron Avatar for raykloss Avatar for james.cutler Avatar for hank Avatar for jeff1 Avatar for tom3 Avatar for marcel Avatar for jonglass Avatar for jkfrench Avatar for schwartz Avatar for ddmiller Avatar for bb1 Avatar for jweil Avatar for Will_M Avatar for mschmitt Avatar for david26 Avatar for phillman5 Avatar for Shamino Avatar for Dafuki Avatar for kineyd9Tpurduol Avatar for GaryS Avatar for david_blanchard