title: Python - String alignment format problem with Thai character
body: <p>I'm working on export the table as <code>.txt</code> file, and I want to look like table so I manually code the table builder. The table builder is correct with English character, but Thai character, there are some point that table border is misaligned.</p>
  <p>I think there has the problem at tonal mark and vowel that counted as length, but actually, one character space may contain the tonal mark and vowel with alphabet up to 3 characters.</p>
  <p>I don't know where to fix the problem.</p>
  <p>Table with English character.</p>
  <pre><code>┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  │                                                        Novice Wish                                                        │
  ├────────────────────────┬────────────────────────────────────────────────┬────────────────────────┬────────────────────────┤
  │   Obtained Datetime    │                   Item Name                    │       Item Type        │         Rarity         │
  ├────────────────────────┼────────────────────────────────────────────────┼────────────────────────┼────────────────────────┤
  │  2020-10-06 13:40:53   │Harbinger of Dawn                               │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Black Tassel                                    │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Skyrider Sword                                  │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Sharpshooter's Oath                             │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Bloodtainted Greatsword                         │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Cool Steel                                      │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Sucrose                                         │       Character        │         4 Star         │
  │  2020-10-06 13:40:53   │Sharpshooter's Oath                             │         Weapon         │         3 Star         │
  │  2020-10-06 13:40:53   │Keqing                                          │       Character        │         5 Star         │
  │  2020-10-06 13:40:53   │Raven Bow                                       │         Weapon         │         3 Star         │
  └────────────────────────┴────────────────────────────────────────────────┴────────────────────────┴────────────────────────┘
  
  Last Update : 2022-04-05 23:20:55
  UID : 801566333
  </code></pre>
  <p>Table with Thai character.</p>
  <pre><code>┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  │                                                การอธิษฐานสำหรับผู้เริ่มต้น                                                │
  ├────────────────────────┬────────────────────────────────────────────────┬────────────────────────┬────────────────────────┤
  │      วันที่ได้รับ      │                      ชื่อ                      │          ชนิด          │         ระดับ          │
  ├────────────────────────┼────────────────────────────────────────────────┼────────────────────────┼────────────────────────┤
  │  2020-10-06 13:40:53   │Harbinger of Dawn                               │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Black Tassel                                    │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Skyrider Sword                                  │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Sharpshooter's Oath                             │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Bloodtainted Greatsword                         │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Cool Steel                                      │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Sucrose                                         │        ตัวละคร         │         4 ดาว          │
  │  2020-10-06 13:40:53   │Sharpshooter's Oath                             │         อาวุธ          │         3 ดาว          │
  │  2020-10-06 13:40:53   │Keqing                                          │        ตัวละคร         │         5 ดาว          │
  │  2020-10-06 13:40:53   │Raven Bow                                       │         อาวุธ          │         3 ดาว          │
  └────────────────────────┴────────────────────────────────────────────────┴────────────────────────┴────────────────────────┘
  
  อัพเดทล่าสุด : 2022-04-05 23:20:55
  UID : 801566333
  </code></pre>
  <p>My table builder code.</p>
  <pre><code>from math import floor
  
  # Table settings
  tableWidth = 120
  tableWidthRatio = [0.2, 0.4, 0.2, 0.2]
  
  def toTable(header,contentTitle,contentList,contentRatio,contentFormat,onModify=None):
    tableContent = &quot;&quot;
    tableContent += (&quot;┌&quot; + &quot;─&quot; * (tableWidth + len(contentTitle) - 1) + &quot;┐\n&quot;)
    tableContent += (&quot;│{:^{}s}│\n&quot;.format(header,tableWidth + len(contentTitle) - 1))
    tableContent += &quot;├&quot;
    for i in range(len(contentTitle)):
      tableContent +=  (&quot;─&quot; * floor(tableWidth * contentRatio[i]))
      if (i &lt; len(contentTitle) - 1):
        tableContent += &quot;┬&quot;
    tableContent += &quot;┤\n&quot;
    tableContent += &quot;│&quot;
    for i in range(len(contentTitle)):
      tableContent +=  (&quot;{:^{}s}&quot;.format(contentTitle[i], floor(tableWidth * contentRatio[i])))
      if (i &lt; len(contentTitle) - 1):
        tableContent += &quot;│&quot;
    tableContent += &quot;│\n&quot;
    tableContent += &quot;├&quot;
    for i in range(len(contentTitle)):
      tableContent +=  (&quot;─&quot; * floor(tableWidth * contentRatio[i]))
      if (i &lt; len(contentTitle) - 1):
        tableContent += &quot;┼&quot;
    tableContent += &quot;┤\n&quot;
    for row in contentList:
      newRow = None
      if onModify == None:
        newRow = row
      else:
        newRow = onModify(row[:])
      for i in range(len(contentTitle)):
        tableContent += &quot;│&quot;
        tableContent += contentFormat[i].format(newRow[i], floor(tableWidth * contentRatio[i]))
      tableContent += &quot;│\n&quot;
    tableContent += &quot;└&quot;
    for i in range(len(contentTitle)):
      tableContent +=  (&quot;─&quot; * floor(tableWidth * contentRatio[i]))
      if (i &lt; len(contentTitle) - 1):
        tableContent += &quot;┴&quot;
    tableContent += &quot;┘&quot;
  
    return tableContent
  </code></pre>