• AmazingAwesomator@lemmy.world
    link
    fedilink
    arrow-up
    25
    ·
    1 day ago

    the fact that these are strings instead of an object that is broken up by country code, area code, and number makes me irrationally angry.

    • Skull giver@popplesburger.hilciferous.nl
      link
      fedilink
      arrow-up
      5
      ·
      edit-2
      7 hours ago

      Country codes are variable. Even the “I’m about to dial another country prefix” (usually + resolves to 00 but that depends on country and carrier) is variable. Phone number lengths are variable. Phone numbers are often written in non-Arabic numerals. Phone numbers can have specific digits in the middle of the number to reroute the call to another carrier.

      You can try to parse phone numbers if you’re writing a specific phone number parsing library, but you’ll need to keep up with the ITU documents, the numbering plans of all countries and satellite providers, and provide support for older standards going back to the 60s. You’ll need to deal with edge cases that your language probably doesn’t even have names for. And most importantly, you’ll have to guess what country the phone number is from based on context clues such as the user’s language or location or locale because phone numbers can be and are reused across borders.

      Phone numbers are worse than time zones. Don’t parse them yourself unless you’re building an international phone interconnect.

      • CanadaPlus@lemmy.sdf.org
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        14 hours ago

        Is there not a “falsehoods programmers think about phone numbers” yet?

        Edit: And once again, I’m still confused about some of these. Do we need to expand unicode for names? It’s supposed to be universal. WTF is up with 40?

        • gandalf_der_12te@discuss.tchncs.de
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          5 hours ago

          WTF is up with 40?

          People have names.

          I suppose that a counterexample to this might be Tibetan children, who get named at puberty, IIRC. Before that, they have no names. They are just referred to as “child” or “somebody’s child”.

          People’s names are all mapped in Unicode code points.

          I suppose a counterexample to that might be cultures which do not use script in general. Then, obviously, there’s no Unicode characters for these non-existant glyphs.

          • CanadaPlus@lemmy.sdf.org
            link
            fedilink
            arrow-up
            1
            ·
            2 hours ago

            Ah, so it dovetails with the whole “children get a name reasonably fast” thing. I was interpreting that as “ever, in a natural lifespan”. My bad, haha.

            I suppose a counterexample to that might be cultures which do not use script in general. Then, obviously, there’s no Unicode characters for these non-existant glyphs.

            True, but there’s little risk of a name being entered into a form without some kind of transcription.

    • wizardbeard@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      23
      ·
      edit-2
      1 day ago

      Could be tests for a parser to convert it from string to object.

      Not like your end users are going to type each piece into a separate field.