Batch processing generates almost any character, including Tab_dos/bat

Source: Internet
Author: User

One of my early posts on dostips is A:CHR routine that could convert a number into the corresponding character. The final code that appears near the "End of" the thread works really, and are fast, but nearly all the characters must Be embedded in the script. The TAB character in particular can is problematic, especially when trying to post the "Code on a forum site."

There is the undocumented%=exitcodeascii% dynamic variable This converts the most error code (from Exit, not exit /b), but it is limited to codes between and 126.

I had never seen a native method to generate a TAB character this works on all Windows Versions-until now

I recently ran across this forfiles documentation gem at ss64.com:

Copy Code code as follows:

To include special characters into the command line with the hex code for the character in 0xHH format (ex. 0x09 is Thetab c Haracter, 0x22 is the double quote "character.)

Eureeka:idea:-The following simple Printhex routine can generate any byte code value except 0x00 (nul), 0x0A (newline), and 0x0D (carriage return). 8)

@echo off
setlocal

::D efine A linefeed variable
set lf=^


:: Above 2 blank lines are critical-do not Remov E.

:: Create a tab variable
call:hexprint "0x09" tab

::P rint A string with encoded TABs call:hexprint
"A0 X09b0x09c "

:: Create A string variable with encoded TABs
call:hexprint" a0x09b0x09c "var
set var

exit

/b: Hexprint string [Rtnvar]
 for/f eol^=^%lf%%lf%^ delims^=%%a in (
  ' forfiles/p '%~dp0. "/M"%~nx0 "/C" cmd/c Echo (%~1 ""
 ) do If "%~2" Neq "" (set%~2=%%a) Else Echo (%%a
exit/b

I ' ll be playing Native American style flutes at a retreat in the Blue Ridge Mountains of Virginia for the next 4 days:D, Without computer access: |
I wanted to post this before I left.

Enjoy the code, while I Enjoy the crisp fall air. :)

Dave Benham

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.