В Unicode, почему есть два представления для арабских цифр?

Вот мое решение для этого

DROP PROCEDURE IF EXISTS findAll;
CREATE PROCEDURE `findAll`( IN `tableName` VARCHAR( 28 ) , IN `search` TEXT )
BEGIN
       DECLARE finished INT DEFAULT FALSE ;
       DECLARE columnName VARCHAR ( 28 ) ;
       DECLARE stmtFields TEXT ;
       DECLARE columnNames CURSOR FOR
              SELECT DISTINCT `COLUMN_NAME` FROM `information_schema`.`COLUMNS`
              WHERE `TABLE_NAME` = tableName ORDER BY `ORDINAL_POSITION` ;
       DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = TRUE;
       SET stmtFields = '' ;
       OPEN columnNames ;
       readColumns: LOOP
              FETCH columnNames INTO columnName ;
              IF finished THEN
                     LEAVE readColumns ;
              END IF;
              SET stmtFields = CONCAT(
                     stmtFields , IF ( LENGTH( stmtFields ) > 0 , ' OR' , ''  ) ,
                     ' `', tableName ,'`.`' , columnName , '` REGEXP "' , search , '"'
              ) ;
       END LOOP;
       SET @stmtQuery := CONCAT ( 'SELECT * FROM `' , tableName , '` WHERE ' , stmtFields ) ;
       PREPARE stmt FROM @stmtQuery ;
       EXECUTE stmt ;
       CLOSE columnNames ;
END;
18
задан Jonathan Leffler 14 November 2014 в 20:23
поделиться

3 ответа

Согласно кодовым таблицам , U + 0660 .. U + 0669 - это АРАБСКИЕ ЦИФРЫ от 0 до 9, а U + 06F0 .. U + 06F9 - РАСШИРЕННЫЕ АРАБСКИЕ ЦИФРЫ, значения от 0 до 9.

В книге Unicode 3.0 (5.2 - текущая версия, но эти вещи не сильно меняются после установки), серия глифов U + 066n помечена как ' It also notes:

  • U+06F4 - 'different glyphs in Persian and Urdu'
  • U+06F5 - 'Persian and Urdu share glyph different from Arabic'
  • U+06F6 - 'Persian glyph different from Arabic'
  • U+06F7 - 'Urdu glyph different from Arabic'

For comparison:

  • U+066n: ٠١٢٣٤٥٦٧٨٩
  • U+06Fn: ۰۱۲۳۴۵۶۷۸۹

Or, enlarged by making the information into a title:

U+066n: ٠١٢٣٤٥٦٧٨٩

U+06Fn: ۰۱۲۳۴۵۶۷۸۹

Or:

     U+066n    U+06Fn
0      ٠         ۰
1      ١         ۱
2      ٢         ۲
3      ٣         ۳
4      ٤         ۴
5      ٥         ۵
6      ٦         ۶
7      ٧         ۷
8      ٨         ۸
9      ٩         ۹

(Whether you can see any of those, and how clearly they are differentiated may depend on your browser and the fonts installed on your machine as much as anything else. I can see the difference on 4 and 6 clearly; 5 looks much the same in both.)

Based on this information, if you are working with Arabic from the Middle East, use the U+066n series of digits; if you are working with Persian or Urdu, use the U+06Fn series of digits. As a Unicode application, you should accept either set of codes as valid digits (but you might look askance at a sequence that mixed the two sets of digits - or you might just leave well alone).

42
ответ дан 30 November 2019 в 06:39
поделиться

Which code do you prefer for representing the number 4, U+0664 or U+06F4?

(٤ or ۴ )?

To be consistent, let this choice guide which codes you use for 1, 2, and the other duplicate codes.

1
ответ дан 30 November 2019 в 06:39
поделиться

В общем, вам не следует жестко кодировать такую ​​информацию в вашем приложении.

  • В Windows вы можете использовать GetLocaleInfo с LOCALE_SNATIVEDIGITS.
  • В Mac CFNumberFormatterCopyProperty с kCFNumberFormatterZeroSymbol.
  • Или используйте что-то вроде ICU .

Арабские страны не используют арабские страны. -Индические цифры по умолчанию. Таким образом, нет прямого сопоставления, говорящего, что арабский -> арабско-индийские цифры.

И пользователь все равно мог изменить значения по умолчанию в панели управления.

4
ответ дан 30 November 2019 в 06:39
поделиться
Другие вопросы по тегам:

Похожие вопросы: