VC 中TEXT、_T、L的区别

VC6.0与VS2005字符集转换详解:L、_T与TEXT
本文深入解析了从VC6.0转至VS2005环境时面对的字符集转换问题,详细介绍了L、_T与TEXT的区别与使用场景,帮助开发者顺利过渡。

VC 中TEXT、_T、L的区别

    对于从VC++6.0转到VS2005编译环境中的程序员。往往会碰到字符集之间的转换。
VC6.0采用的是ANSI字符集,而VS2005或者VS2008是采用的Unicode字符集。
L:
比如创建一个窗口类:HWND hWnd=CreateWindow(L"ClassName",L"最简单的Direct3D程序",
                            WS_OVERLAPPEDWINDOW,200,100,600,500,
                            NULL,NULL,wc.hInstance,NULL);
L的作用:是将ANSI字符串转换成Unicode字符串,也就是每个字符占用两个字节。比如:
   strlen("asd")=3;
   strlen(L"asd")=6;

_T:
  _T宏可以把一个引号引起来的字符串,根据你的环境设置,使得编译器会根据编译目标环境选择合适的(Unicode还是ANSI)字符处理方式
   如果你定义了UNICODE,那么_T宏会把字符串前面加一个L。这时 _T("ABCD") 相当于L"ABCD",这是宽字符串。 如果没有定义,那么_T宏不会在字符串前面加那个L,_T("ABCD") 就等价于"ABCD" 因此_T相当于自动转换字符集。

TEXT:  功能与_T相似,在 ASCII 模式下,它们被忽略,也就是说被预处理器删除掉,但是如果定义了UNICODE, 则它们会将常量字符串转换成等价的 UNICODE 。
   TEXT 宏的主要作用是当定义了 UNICODE/_UNICODE 预处理指令时,字符串被标志为双字节字符串,否则字符串被标示为 ANSI 字符串。

TEXT 的定义如下:
TEXT( LPTSTR string // ANSI 或者 Unicode 字符串 );

with vHgInfoTable as ( select a.l_hg_date, a.l_redeem_lawdate, a.l_redeem_liquidate, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.c_entrust_direction, max( case when b.c_entrust_direction in ('15','16','17','18','26','27','30', '31','35','36','37','38','39','40') then a.L_REDEEM_DAYS else nvl((to_date(a.l_settle_date, 'YYYYMMDD') - (select min(to_date(tm.l_date, 'YYYYMMDD')) from tmarkettradeday tm where tm.l_Date > a.l_hg_date and tm.vc_tradeday_type = j.vc_tradeday_type and tm.c_trade_flag In ('1', '3'))),0) end) l_use_days, sum(a.l_deal_amount) l_deal_amount, sum(decode(b.c_fund_direction, '1', 1, -1) * a.en_deal_balance - a.en_fee) en_net_zj, sum(decode(b.c_entrust_direction, '5', -1, 1) * a.en_now_interest) en_now_interest, sum(decode(b.c_fund_direction, '1', -1, 1) * (a.en_deal_balance + a.en_redeem_interest)) en_ret_zj, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest - a.en_fee) en_profit, sum(a.en_redeem_interest - a.en_fee - (a.en_deal_balance + a.en_fee) * nvl((select en_ratio from (select en_year_rate / l_days en_ratio, l_fund_id, l_org_id from TINTERESTRATE where vc_currency_no = 'CNY' and l_rate_type = '1' order by l_org_id desc, l_fund_id desc) vi where ((vi.l_fund_id = a.l_fund_id) or (vi.l_fund_id = -1)) and ((vi.l_org_id = tfd.l_org_id) or (vi.l_org_id = -1)) and rownum = 1), 0) * decode(a.l_redeem_days, 3, decode(to_number(to_char(to_date(to_char(a.l_date, 99999999), 'yyyymmdd'), 'd')), 2, 3, 3, 5, 4, 5, 5, 4, 6, 1, a.l_redeem_days), a.l_redeem_days)) en_extra_profit, min(b.vc_entrustdir_name) vc_entrustdir_name, a.vc_inter_code, (case when count(distinct(a.l_fund_id)) = 1 then min(a.l_fund_id) else -1 end) l_fund_id, (case when count(distinct(a.vc_stockholder_id)) = 1 then min(a.vc_stockholder_id) else '混合' end) vc_stockholder_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_no) else '混合' end) vc_combi_no, (case when count(distinct(a.l_basecombi_id)) = 1 then min(a.l_basecombi_id) else -1 end) l_combi_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_name) else '混合' end) vc_combi_name, (case when count(distinct(e.l_asset_id)) = 1 then min(e.l_asset_id) else -1 end) l_asset_id, '' vc_asset_name, '' vc_asset_no, (case when count(distinct(a.l_operator_no)) = 1 then min(a.l_operator_no) else -1 end) l_operator_no, a.c_redeal_flag, decode(sum(a.l_deal_amount), 0, 0, sum(a.en_deal_price * a.l_Deal_Amount) / sum(a.l_deal_amount)) en_avgInterest, (case when count(distinct(tfd.l_org_id)) = 1 then min(tfd.l_org_id) else -1 end) l_org_id, '' vc_org_name, '' vc_org_code, '' VC_CAPITAL_ACCOUNT, min(j.vc_market_name) vc_market_name, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest) en_redeem_interest, sum(a.en_fee) en_fee from THGREGISTER a, TENTRUSTDIRECTION b, TMARKETINFO J, TCOMBI e, tfundinfo tfd where a.c_entrust_direction = b.c_entrust_direction and a.c_market_no = b.c_market_no and a.c_market_no = j.c_market_no and a.l_basecombi_id = e.l_combi_id and a.l_fund_id = tfd.l_fund_id and tfd.l_org_id in ( tfd.l_org_id ) and a.C_STOCK_TYPE in ( a.c_stock_type ) and a.c_market_no in ('1', '2') and not exists (select l_hgregister_serial_no from TDELAYDEALHGREGISTER t where t.l_hgregister_serial_no = a.l_serial_no and t.l_fund_id in ( a.l_fund_id ) and t.l_basecombi_id in ( e.l_combi_id ) and t.vc_stockholder_id in ( a.vc_stockholder_id ) and ((t.vc_inter_code = '-1' ) or ( '-1' = '-1')) and ((t.l_hg_date between '-1' and '-1' ) or ( '-1' = '-1'))) and a.l_fund_id in ( a.l_fund_id ) and a.vc_stockholder_id in ( a.vc_stockholder_id ) -- and e.l_asset_id in ( ^sAssetId ) and e.l_combi_id in ( e.l_combi_id ) and ((a.vc_inter_code = '-1' ) or ( '-1' = '-1')) and ((e.c_combi_status = '1' ) or ( '1' = '-1')) and ((a.l_hg_date between '-1' and '-1' ) or ( '-1' = '-1')) and ((a.l_redeem_lawdate between '-1' and '-1' ) or ( '-1' = '-1')) and ((a.l_redeem_liquidate between '-1' and '-1' ) or ( '-1' = '-1')) and ((a.c_redeal_flag <> '1') or ( '-1' = '-1')) and ((a.c_redeal_flag = '0') or ((a.c_redeal_flag = '1') and (a.l_redeem_liquidate = '20250220' )) or ( '0' = '-1')) and ((a.c_redeal_flag = '0') or ((a.c_redeal_flag = '1') and (a.l_redeem_liquidate < '20250220' )) or ( '-1' = '-1')) and a.C_ENTRUST_DIRECTION in ('5','6','15','16') and (select count(*)from topfundright where topfundright.l_asset_id = e.l_asset_id and topfundright.c_layer = '2' and topfundright.l_operator_no = 1000 and instr(topfundright.vc_rights, '1') > 0) > 0 group by a.l_hg_date, a.l_redeem_lawdate, a.l_redeem_liquidate, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.vc_inter_code, a.C_ENTRUST_DIRECTION, a.c_redeal_flag ,a.l_fund_id ,e.l_asset_id ,a.vc_stockholder_id ,a.l_operator_no union all select a.L_NEW_HG_DATE l_hg_date, a.l_redeem_lawdate, a.L_NEW_REDEEM_LIQUIDATE l_redeem_liquidate, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.c_entrust_direction, max( case when b.c_entrust_direction in ('15','16','17','18','26','27','30', '31','35','36','37','38','39','40') then a.L_REDEEM_DAYS else nvl((to_date(a.l_settle_date, 'YYYYMMDD') - (select min(to_date(tm.l_date, 'YYYYMMDD')) from tmarkettradeday tm where tm.l_Date > a.L_NEW_HG_DATE and tm.vc_tradeday_type = j.vc_tradeday_type and tm.c_trade_flag In ('1', '3'))),0) end) l_use_days, sum(a.l_deal_amount) l_deal_amount, sum(decode(b.c_fund_direction, '1', 1, -1) * a.en_deal_balance - a.en_fee) en_net_zj, sum(decode(b.c_entrust_direction, '5', -1, 1) * a.en_now_interest) en_now_interest, sum(decode(b.c_fund_direction, '1', -1, 1) * (a.en_deal_balance + a.en_redeem_interest)) en_ret_zj, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest - a.en_fee) en_profit, sum(a.en_redeem_interest - a.en_fee - (a.en_deal_balance + a.en_fee) * nvl((select en_ratio from (select en_year_rate / l_days en_ratio, l_fund_id, l_org_id from TINTERESTRATE where vc_currency_no = 'CNY' and l_rate_type = '1' order by l_org_id desc, l_fund_id desc) vi where ((vi.l_fund_id = a.l_fund_id) or (vi.l_fund_id = -1)) and ((vi.l_org_id = tfd.l_org_id) or (vi.l_org_id = -1)) and rownum = 1), 0) * decode(a.l_redeem_days, 3, decode(to_number(to_char(to_date(to_char(a.l_date, 99999999), 'yyyymmdd'), 'd')), 2, 3, 3, 5, 4, 5, 5, 4, 6, 1, a.l_redeem_days), a.l_redeem_days)) en_extra_profit, min(b.vc_entrustdir_name) vc_entrustdir_name, a.vc_inter_code, (case when count(distinct(a.l_fund_id)) = 1 then min(a.l_fund_id) else -1 end) l_fund_id, (case when count(distinct(a.vc_stockholder_id)) = 1 then min(a.vc_stockholder_id) else '混合' end) vc_stockholder_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_no) else '混合' end) vc_combi_no, (case when count(distinct(a.l_basecombi_id)) = 1 then min(a.l_basecombi_id) else -1 end) l_combi_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_name) else '混合' end) vc_combi_name, (case when count(distinct(e.l_asset_id)) = 1 then min(e.l_asset_id) else -1 end) l_asset_id, '' vc_asset_name, '' vc_asset_no, (case when count(distinct(a.l_operator_no)) = 1 then min(a.l_operator_no) else -1 end) l_operator_no, a.c_redeal_flag, decode(sum(a.l_deal_amount), 0, 0, sum(a.en_deal_price * a.l_Deal_Amount) / sum(a.l_deal_amount)) en_avgInterest, (case when count(distinct(tfd.l_org_id)) = 1 then min(tfd.l_org_id) else -1 end) l_org_id, '' vc_org_name, '' vc_org_code, '' VC_CAPITAL_ACCOUNT, min(j.vc_market_name) vc_market_name, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest) en_redeem_interest, sum(a.en_fee) en_fee from TDELAYDEALHGREGISTER a, TENTRUSTDIRECTION b, TMARKETINFO J, TCOMBI e, tfundinfo tfd, tstockinfo ts where a.c_entrust_direction = b.c_entrust_direction and a.c_market_no = b.c_market_no and a.c_market_no = j.c_market_no and a.l_basecombi_id = e.l_combi_id and a.l_fund_id = tfd.l_fund_id and tfd.l_org_id in ( tfd.l_org_id ) and a.c_market_no in ('1', '2') and a.l_fund_id in ( a.l_fund_id) and a.VC_INTER_CODE = ts.VC_INTER_CODE and ts.C_STOCK_TYPE in ( ts.c_stock_type ) and a.vc_stockholder_id in ( a.vc_stockholder_id ) -- and e.l_asset_id in ( ^sAssetId ) and e.l_combi_id in ( e.l_combi_id ) and ((a.vc_inter_code = '-1' ) or ( '-1' = '-1')) and ((e.c_combi_status = '1' ) or ( '1' = '-1')) and ((a.L_NEW_HG_DATE between '-1' and '-1') or ( '-1' = '-1')) and ((a.l_redeem_lawdate between '-1' and '-1' ) or ( '-1' = '-1')) and ((a.L_NEW_REDEEM_LIQUIDATE between '-1' and '-1' ) or ( '-1' = '-1')) and ((a.c_redeal_flag <> '1') or ( '-1' = '-1')) and ((a.c_redeal_flag = '0') or ((a.c_redeal_flag = '1') and (a.L_NEW_REDEEM_LIQUIDATE = '20250220' )) or ( '0' = '-1')) and ((a.c_redeal_flag = '0') or ((a.c_redeal_flag = '1') and (a.L_NEW_REDEEM_LIQUIDATE < '20250220' )) or ( '-1' = '-1')) and a.C_ENTRUST_DIRECTION in ('5','6','15','16') and (select count(*)from topfundright where topfundright.l_asset_id = e.l_asset_id and topfundright.c_layer = '2' and topfundright.l_operator_no = 1000 and instr(topfundright.vc_rights, '1') > 0) > 0 group by a.L_NEW_HG_DATE, a.l_redeem_lawdate, a.L_NEW_REDEEM_LIQUIDATE, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.vc_inter_code, a.C_ENTRUST_DIRECTION, a.c_redeal_flag ,a.l_fund_id ,e.l_asset_id ,a.vc_stockholder_id ,a.l_operator_no union all select a.l_hg_date, a.l_redeem_lawdate, a.l_redeem_liquidate, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.c_entrust_direction, max( case when b.c_entrust_direction in ('15','16','17','18','26','27','30', '31','35','36','37','38','39','40') then a.L_REDEEM_DAYS else nvl((to_date(a.l_settle_date, 'YYYYMMDD') - (select min(to_date(tm.l_date, 'YYYYMMDD')) from tmarkettradeday tm where tm.l_Date > a.l_hg_date --20160527 20160531 and tm.vc_tradeday_type = j.vc_tradeday_type and tm.c_trade_flag In ('1', '3'))),0) end) l_use_days, sum(a.l_deal_amount) l_deal_amount, sum(decode(b.c_fund_direction, '1', 1, -1) * a.en_deal_balance - a.en_fee) en_net_zj, sum(decode(b.c_entrust_direction, '5', -1, 1) * a.en_now_interest) en_now_interest, sum(decode(b.c_fund_direction, '1', -1, 1) * (a.en_deal_balance + a.en_redeem_interest)) en_ret_zj, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest - a.en_fee) en_profit, sum(a.en_redeem_interest - a.en_fee - (a.en_deal_balance + a.en_fee) * nvl((select en_ratio from (select en_year_rate / l_days en_ratio, l_fund_id, l_org_id from TINTERESTRATE where vc_currency_no = 'CNY' and l_rate_type = '1' order by l_org_id desc, l_fund_id desc) vi where ((vi.l_fund_id = a.l_fund_id) or (vi.l_fund_id = -1)) and ((vi.l_org_id = tfd.l_org_id) or (vi.l_org_id = -1)) and rownum = 1), 0) * decode(a.l_redeem_days, 3, decode(to_number(to_char(to_date(to_char(a.l_date, 99999999), 'yyyymmdd'), 'd')), 2, 3, 3, 5, 4, 5, 5, 4, 6, 1, a.l_redeem_days), a.l_redeem_days)) en_extra_profit, min(b.vc_entrustdir_name) vc_entrustdir_name, a.vc_inter_code, (case when count(distinct(a.l_fund_id)) = 1 then min(a.l_fund_id) else -1 end) l_fund_id, (case when count(distinct(a.vc_stockholder_id)) = 1 then min(a.vc_stockholder_id) else '混合' end) vc_stockholder_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_no) else '混合' end) vc_combi_no, (case when count(distinct(a.l_basecombi_id)) = 1 then min(a.l_basecombi_id) else -1 end) l_combi_id, (case when count(distinct(a.l_basecombi_id)) = 1 then min(e.vc_combi_name) else '混合' end) vc_combi_name, (case when count(distinct(e.l_asset_id)) = 1 then min(e.l_asset_id) else -1 end) l_asset_id, '' vc_asset_name, '' vc_asset_no, (case when count(distinct(a.l_operator_no)) = 1 then min(a.l_operator_no) else -1 end) l_operator_no, a.c_redeal_flag, decode(sum(a.l_deal_amount), 0, 0, sum(a.en_deal_price * a.l_Deal_Amount) / sum(a.l_deal_amount)) en_avgInterest, (case when count(distinct(tfd.l_org_id)) = 1 then min(tfd.l_org_id) else -1 end) l_org_id, '' vc_org_name, '' vc_org_code, '' VC_CAPITAL_ACCOUNT, min(j.vc_market_name) vc_market_name, sum(decode(b.c_fund_direction, '1', -1, 1) * a.en_redeem_interest) en_redeem_interest, sum(a.en_fee) en_fee from ThisHGREGISTER a, TENTRUSTDIRECTION b, TMARKETINFO J, TCOMBI e, tfundinfo tfd where a.c_entrust_direction = b.c_entrust_direction and a.c_market_no = b.c_market_no and a.c_market_no = j.c_market_no and a.l_basecombi_id = e.l_combi_id and a.l_fund_id = tfd.l_fund_id and tfd.l_org_id in ( tfd.l_org_id ) and a.c_market_no in ('1', '2') and a.l_fund_id in ( a.l_fund_id ) and a.C_STOCK_TYPE in ( a.c_stock_type ) and a.vc_stockholder_id in ( a.vc_stockholder_id ) -- and e.l_asset_id in ( ^sAssetId ) and e.l_combi_id in ( e.l_combi_id ) and ((a.vc_inter_code = '-1' ) or ( '-1' = '-1')) and ((e.c_combi_status = '1' ) or ( '1' = '-1')) and ((a.l_hg_date between '-1' and '-1' ) or ( '-1' = '-1' )) and ((a.l_redeem_lawdate between '-1' and '-1' ) or ( '-1' = '-1' )) and ((a.l_redeem_liquidate between '-1' and '-1' ) or ( '-1' = '-1')) and '-1' = '1' and ((a.c_redeal_flag <> '1') or ( '0' = '-1')) and a.C_ENTRUST_DIRECTION in ('5','6','15','16') and (select count(*)from topfundright where topfundright.l_asset_id = e.l_asset_id and topfundright.c_layer = '2' and topfundright.l_operator_no = 1000 and instr(topfundright.vc_rights, '1') > 0) > 0 group by a.l_hg_date, a.l_redeem_lawdate, a.l_redeem_liquidate, a.l_settle_date, a.l_redeal_date, a.l_settle_speed, a.vc_inter_code, a.C_ENTRUST_DIRECTION, a.c_redeal_flag ,a.l_fund_id ,e.l_asset_id ,a.vc_stockholder_id ,a.l_operator_no ) select * from (select count(distinct rnum) over() as totalrn, rownum rn, tp.* from (select count(0) over() as total, dense_rank() over( order by t.l_fund_id,t.vc_inter_code desc,t.c_entrust_direction ) as rnum, t.* from ( select * from vHgInfoTable a order by a.l_fund_id,a.vc_inter_code desc,a.c_entrust_direction ) t ) tp )t3 where t3.rnum >= 1 and t3.rnum <= 50 order by t3.rnum 详细说明上面sql,最后查出来的数据是什么条件过滤的从哪个表取得什么字段
最新发布
05-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值