File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1627,7 +1627,31 @@ Unicode range UTF-8 bytes
1627
1627
(m_pCurrentLine->len >= m_pCurrentLine->iMemoryAllocated )) // emergency bail-out
1628
1628
{
1629
1629
1630
- // do auto line wrapping here
1630
+ // do auto line wrapping here
1631
+
1632
+ // first see if we can split at a multibyte character if no space was found
1633
+
1634
+ if (m_pCurrentLine->last_space < 0 && // no space found
1635
+ (m_pCurrentLine->len - m_pCurrentLine->last_space ) >= m_nWrapColumn &&
1636
+ m_pCurrentLine->len >= 10 &&
1637
+ !m_bUTF_8) // not for UTF-8
1638
+ {
1639
+ int multibyte_start = -1 ;
1640
+ for (int i = 0 ; i < m_pCurrentLine->len - 1 ; i++)
1641
+ {
1642
+ unsigned char c1 = m_pCurrentLine->text [i];
1643
+ unsigned char c2 = m_pCurrentLine->text [i + 1 ];
1644
+ if (c1 >= 0x81 && c1 <= 0xFE && // first Big5 character
1645
+ ((c2 >= 0x40 && c2 <= 0x7E ) || (c2 >= 0xA1 && c2 <= 0xFE ))) // second Big5 character
1646
+ multibyte_start = i++; // remember position, jump the second byte
1647
+ else if (c1 >= 0xA1 && c1 <= 0xF7 && c2 >= 0xA1 && c2 <= 0xFE ) // GB2132
1648
+ multibyte_start = i++; // remember position, jump the second byte
1649
+ else if (c1 <= 0x7F )
1650
+ multibyte_start = i; // we can split after any ordinary character
1651
+ }
1652
+
1653
+ m_pCurrentLine->last_space = multibyte_start;
1654
+ } // end of checking for a Big5 or GB2132 break point
1631
1655
1632
1656
if (!m_wrap ||
1633
1657
m_pCurrentLine->last_space < 0 ||
You can’t perform that action at this time.
0 commit comments