Karsten Hopp 99be62
To: vim_dev@googlegroups.com
Karsten Hopp 99be62
Subject: Patch 7.3.780
Karsten Hopp 99be62
Fcc: outbox
Karsten Hopp 99be62
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 99be62
Mime-Version: 1.0
Karsten Hopp 99be62
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 99be62
Content-Transfer-Encoding: 8bit
Karsten Hopp 99be62
------------
Karsten Hopp 99be62
Karsten Hopp 99be62
Patch 7.3.780
Karsten Hopp 99be62
Problem:    char2nr() and nr2char() always use 'encoding'.
Karsten Hopp 99be62
Solution:   Add argument to use utf-8 characters. (Yasuhiro Matsumoto)
Karsten Hopp 99be62
Files:	    runtime/doc/eval.txt, src/eval.c
Karsten Hopp 99be62
Karsten Hopp 99be62
Karsten Hopp 99be62
*** ../vim-7.3.779/runtime/doc/eval.txt	2012-12-05 16:10:21.000000000 +0100
Karsten Hopp 99be62
--- runtime/doc/eval.txt	2013-01-23 17:00:52.000000000 +0100
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 1705,1711 ****
Karsten Hopp 99be62
  				any	call {func} with arguments {arglist}
Karsten Hopp 99be62
  ceil( {expr})			Float	round {expr} up
Karsten Hopp 99be62
  changenr()			Number	current change number
Karsten Hopp 99be62
! char2nr( {expr})		Number	ASCII value of first char in {expr}
Karsten Hopp 99be62
  cindent( {lnum})		Number	C indent for line {lnum}
Karsten Hopp 99be62
  clearmatches()			none	clear all matches
Karsten Hopp 99be62
  col( {expr})			Number	column nr of cursor or mark
Karsten Hopp 99be62
--- 1716,1722 ----
Karsten Hopp 99be62
  				any	call {func} with arguments {arglist}
Karsten Hopp 99be62
  ceil( {expr})			Float	round {expr} up
Karsten Hopp 99be62
  changenr()			Number	current change number
Karsten Hopp 99be62
! char2nr( {expr}[, {utf8}])	Number	ASCII/UTF8 value of first char in {expr}
Karsten Hopp 99be62
  cindent( {lnum})		Number	C indent for line {lnum}
Karsten Hopp 99be62
  clearmatches()			none	clear all matches
Karsten Hopp 99be62
  col( {expr})			Number	column nr of cursor or mark
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 1862,1868 ****
Karsten Hopp 99be62
  mode( [expr])			String	current editing mode
Karsten Hopp 99be62
  mzeval( {expr})			any	evaluate |MzScheme| expression
Karsten Hopp 99be62
  nextnonblank( {lnum})		Number	line nr of non-blank line >= {lnum}
Karsten Hopp 99be62
! nr2char( {expr})		String	single char with ASCII value {expr}
Karsten Hopp 99be62
  or( {expr}, {expr})		Number  bitwise OR
Karsten Hopp 99be62
  pathshorten( {expr})		String	shorten directory names in a path
Karsten Hopp 99be62
  pow( {x}, {y})			Float	{x} to the power of {y}
Karsten Hopp 99be62
--- 1873,1879 ----
Karsten Hopp 99be62
  mode( [expr])			String	current editing mode
Karsten Hopp 99be62
  mzeval( {expr})			any	evaluate |MzScheme| expression
Karsten Hopp 99be62
  nextnonblank( {lnum})		Number	line nr of non-blank line >= {lnum}
Karsten Hopp 99be62
! nr2char( {expr}[, {utf8}])	String	single char with ASCII/UTF8 value {expr}
Karsten Hopp 99be62
  or( {expr}, {expr})		Number  bitwise OR
Karsten Hopp 99be62
  pathshorten( {expr})		String	shorten directory names in a path
Karsten Hopp 99be62
  pow( {x}, {y})			Float	{x} to the power of {y}
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 2282,2295 ****
Karsten Hopp 99be62
  		redo it is the number of the redone change.  After undo it is
Karsten Hopp 99be62
  		one less than the number of the undone change.
Karsten Hopp 99be62
  
Karsten Hopp 99be62
! char2nr({expr})						*char2nr()*
Karsten Hopp 99be62
  		Return number value of the first char in {expr}.  Examples: >
Karsten Hopp 99be62
  			char2nr(" ")		returns 32
Karsten Hopp 99be62
  			char2nr("ABC")		returns 65
Karsten Hopp 99be62
! <		The current 'encoding' is used.  Example for "utf-8": >
Karsten Hopp 99be62
  			char2nr("รก")		returns 225
Karsten Hopp 99be62
  			char2nr("รก"[0])		returns 195
Karsten Hopp 99be62
! <		|nr2char()| does the opposite.
Karsten Hopp 99be62
  
Karsten Hopp 99be62
  cindent({lnum})						*cindent()*
Karsten Hopp 99be62
  		Get the amount of indent for line {lnum} according the C
Karsten Hopp 99be62
--- 2294,2310 ----
Karsten Hopp 99be62
  		redo it is the number of the redone change.  After undo it is
Karsten Hopp 99be62
  		one less than the number of the undone change.
Karsten Hopp 99be62
  
Karsten Hopp 99be62
! char2nr({expr}[, {utf8}])					*char2nr()*
Karsten Hopp 99be62
  		Return number value of the first char in {expr}.  Examples: >
Karsten Hopp 99be62
  			char2nr(" ")		returns 32
Karsten Hopp 99be62
  			char2nr("ABC")		returns 65
Karsten Hopp 99be62
! <		When {utf8} is omitted or zero, the current 'encoding' is used.
Karsten Hopp 99be62
! 		Example for "utf-8": >
Karsten Hopp 99be62
  			char2nr("รก")		returns 225
Karsten Hopp 99be62
  			char2nr("รก"[0])		returns 195
Karsten Hopp 99be62
! <		With {utf8} set to 1, always treat as utf-8 characters.
Karsten Hopp 99be62
! 		A combining character is a separate character.
Karsten Hopp 99be62
! 		|nr2char()| does the opposite.
Karsten Hopp 99be62
  
Karsten Hopp 99be62
  cindent({lnum})						*cindent()*
Karsten Hopp 99be62
  		Get the amount of indent for line {lnum} according the C
Karsten Hopp 99be62
*** ../vim-7.3.779/src/eval.c	2013-01-23 15:53:08.000000000 +0100
Karsten Hopp 99be62
--- src/eval.c	2013-01-23 16:57:48.000000000 +0100
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 7854,7860 ****
Karsten Hopp 99be62
      {"ceil",		1, 1, f_ceil},
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {"changenr",	0, 0, f_changenr},
Karsten Hopp 99be62
!     {"char2nr",		1, 1, f_char2nr},
Karsten Hopp 99be62
      {"cindent",		1, 1, f_cindent},
Karsten Hopp 99be62
      {"clearmatches",	0, 0, f_clearmatches},
Karsten Hopp 99be62
      {"col",		1, 1, f_col},
Karsten Hopp 99be62
--- 7854,7860 ----
Karsten Hopp 99be62
      {"ceil",		1, 1, f_ceil},
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {"changenr",	0, 0, f_changenr},
Karsten Hopp 99be62
!     {"char2nr",		1, 2, f_char2nr},
Karsten Hopp 99be62
      {"cindent",		1, 1, f_cindent},
Karsten Hopp 99be62
      {"clearmatches",	0, 0, f_clearmatches},
Karsten Hopp 99be62
      {"col",		1, 1, f_col},
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 8003,8009 ****
Karsten Hopp 99be62
      {"mzeval",		1, 1, f_mzeval},
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {"nextnonblank",	1, 1, f_nextnonblank},
Karsten Hopp 99be62
!     {"nr2char",		1, 1, f_nr2char},
Karsten Hopp 99be62
      {"or",		2, 2, f_or},
Karsten Hopp 99be62
      {"pathshorten",	1, 1, f_pathshorten},
Karsten Hopp 99be62
  #ifdef FEAT_FLOAT
Karsten Hopp 99be62
--- 8003,8009 ----
Karsten Hopp 99be62
      {"mzeval",		1, 1, f_mzeval},
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {"nextnonblank",	1, 1, f_nextnonblank},
Karsten Hopp 99be62
!     {"nr2char",		1, 2, f_nr2char},
Karsten Hopp 99be62
      {"or",		2, 2, f_or},
Karsten Hopp 99be62
      {"pathshorten",	1, 1, f_pathshorten},
Karsten Hopp 99be62
  #ifdef FEAT_FLOAT
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 9303,9309 ****
Karsten Hopp 99be62
  {
Karsten Hopp 99be62
  #ifdef FEAT_MBYTE
Karsten Hopp 99be62
      if (has_mbyte)
Karsten Hopp 99be62
! 	rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
Karsten Hopp 99be62
      else
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      rettv->vval.v_number = get_tv_string(&argvars[0])[0];
Karsten Hopp 99be62
--- 9303,9319 ----
Karsten Hopp 99be62
  {
Karsten Hopp 99be62
  #ifdef FEAT_MBYTE
Karsten Hopp 99be62
      if (has_mbyte)
Karsten Hopp 99be62
!     {
Karsten Hopp 99be62
! 	int	utf8 = 0;
Karsten Hopp 99be62
! 
Karsten Hopp 99be62
! 	if (argvars[1].v_type != VAR_UNKNOWN)
Karsten Hopp 99be62
! 	    utf8 = get_tv_number_chk(&argvars[1], NULL);
Karsten Hopp 99be62
! 
Karsten Hopp 99be62
! 	if (utf8)
Karsten Hopp 99be62
! 	    rettv->vval.v_number = (*utf_ptr2char)(get_tv_string(&argvars[0]));
Karsten Hopp 99be62
! 	else
Karsten Hopp 99be62
! 	    rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
Karsten Hopp 99be62
!     }
Karsten Hopp 99be62
      else
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      rettv->vval.v_number = get_tv_string(&argvars[0])[0];
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 14360,14366 ****
Karsten Hopp 99be62
  
Karsten Hopp 99be62
  #ifdef FEAT_MBYTE
Karsten Hopp 99be62
      if (has_mbyte)
Karsten Hopp 99be62
! 	buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
Karsten Hopp 99be62
      else
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {
Karsten Hopp 99be62
--- 14370,14385 ----
Karsten Hopp 99be62
  
Karsten Hopp 99be62
  #ifdef FEAT_MBYTE
Karsten Hopp 99be62
      if (has_mbyte)
Karsten Hopp 99be62
!     {
Karsten Hopp 99be62
! 	int	utf8 = 0;
Karsten Hopp 99be62
! 
Karsten Hopp 99be62
! 	if (argvars[1].v_type != VAR_UNKNOWN)
Karsten Hopp 99be62
! 	    utf8 = get_tv_number_chk(&argvars[1], NULL);
Karsten Hopp 99be62
! 	if (utf8)
Karsten Hopp 99be62
! 	    buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
Karsten Hopp 99be62
! 	else
Karsten Hopp 99be62
! 	    buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
Karsten Hopp 99be62
!     }
Karsten Hopp 99be62
      else
Karsten Hopp 99be62
  #endif
Karsten Hopp 99be62
      {
Karsten Hopp 99be62
*** ../vim-7.3.779/src/version.c	2013-01-23 16:43:07.000000000 +0100
Karsten Hopp 99be62
--- src/version.c	2013-01-23 17:06:36.000000000 +0100
Karsten Hopp 99be62
***************
Karsten Hopp 99be62
*** 727,728 ****
Karsten Hopp 99be62
--- 727,730 ----
Karsten Hopp 99be62
  {   /* Add new patch number below this line */
Karsten Hopp 99be62
+ /**/
Karsten Hopp 99be62
+     780,
Karsten Hopp 99be62
  /**/
Karsten Hopp 99be62
Karsten Hopp 99be62
-- 
Karsten Hopp 99be62
A real patriot is the fellow who gets a parking ticket and rejoices
Karsten Hopp 99be62
that the system works.
Karsten Hopp 99be62
Karsten Hopp 99be62
Karsten Hopp 99be62
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 99be62
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 99be62
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 99be62
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///