| |

VerySource

 Forgot password?
 Register
Search
View: 603|Reply: 7

How to convert TCHAR type to double type (Unicode encoding)

[Copy link]

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 United States

Post time: 2020-3-11 18:30:01
| Show all posts |Read mode
How to convert TCHAR type to double type
E.g:
char str;
double d;
d = atof (str);
Can be compiled and passed, because Unicode encoding is needed, char needs to be converted to TCHAR
TCHAR str;
The above will not work. How to deal with
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-6-4 19:45:01
| Show all posts
_tstof
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-6-4 22:45:01
| Show all posts
_tstof TCHAR to double
It is used to replace atof, which can be applied to both mbcs and unicode character encoding
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-5 22:30:01
| Show all posts
Thanks to the brothers upstairs for their help, it is now operational.
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-6 10:00:02
| Show all posts
According to this statement
_tstoi can replace atoi
_tstol can replace atol
Wait, but there is one more
What's the matter with _tstof_l?
Thank you for your explanation
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-6-6 19:15:01
| Show all posts
In fact, all the runtime library functions, the string operation functions printf and sprintf that we are used to have their corresponding unicode version and tchar version
Most of the tchar version can do this, for example, strlen, change to _tcslen(), which means that str becomes _tcs

printf can be changed to _tprintf, most can be handled in this way

Involved parameters contain string constants like printf(""), all become _tprintf(_T("...")) like this,

All of the above are done for compatibility with previous runtime functions

For some standard API functions, such as MessageBoxA and MessageBoxW, macros are replaced by MessageBox automatic recognition environment. Try to use _T() in the parameter to contain the string constant, if it is a pointer to a variable string
LPTSTR is used to replace unsigned char *
LPCTSTR is used to replace const unsigned char *
What about arrays is TCHAR[]

When calculating the size of a byte, pay attention to that the correct number of TCHAR[100] is 100*sizeof(TCHAR) instead of just 100
The program written in this way can cope with compilation in two environments
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-6-7 14:45:01
| Show all posts
_tstof_l? Is there this?
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-7 22:30:01
| Show all posts
Yes, there is
_tstol_l
_tstoi_l
_tstoi64
_tstoi64_l
Wait
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list