rust-lang / rust-lang/rust-bindgen
File decode support
Open
Nobody has claimed this yet.
enhancement
help wanted
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
My CPP source code is encoded with GBK, is there any API to support another file encoding?
There is binding auto-generated by bindgen but got a garbled document,like this
#[doc = "�������"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CThostFtdcDepthMarketDataField {
#[doc = "������"]
pub TradingDay: TThostFtdcDateType,
#[doc = "��Լ����"]
pub InstrumentID: TThostFtdcInstrumentIDType,
#[doc = "����������"]
pub ExchangeID: TThostFtdcExchangeIDType,
#[doc = "��Լ�ڽ������Ĵ���"]
pub ExchangeInstID: TThostFtdcExchangeInstIDType,
#[doc = "���¼�"]
pub LastPrice: TThostFtdcPriceType,
#[doc = "�ϴν����"]
pub PreSettlementPrice: TThostFtdcPriceType,
#[doc = "������"]
pub PreClosePrice: TThostFtdcPriceType,
#[doc = "��\u{5b2}���"]
pub PreOpenInterest: TThostFtdcLargeVolumeType,
#[doc = "����"]
pub OpenPrice: TThostFtdcPriceType,
#[doc = "��\u{7fc}�"]
pub HighestPrice: TThostFtdcPriceType,
#[doc = "��ͼ�"]
pub LowestPrice: TThostFtdcPriceType,
#[doc = "����"]
pub Volume: TThostFtdcVolumeType,
#[doc = "�ɽ����"]
pub Turnover: TThostFtdcMoneyType,
#[doc = "�\u{5b2}���"]
pub OpenInterest: TThostFtdcLargeVolumeType,
#[doc = "������"]
pub ClosePrice: TThostFtdcPriceType,
#[doc = "������"]
pub SettlementPrice: TThostFtdcPriceType,
#[doc = "��\u{363}���"]
pub UpperLimitPrice: TThostFtdcPriceType,
#[doc = "��\u{363}���"]
pub LowerLimitPrice: TThostFtdcPriceType,
#[doc = "����ʵ��"]
pub PreDelta: TThostFtdcRatioType,
#[doc = "����ʵ��"]
pub CurrDelta: TThostFtdcRatioType,
#[doc = "����\u{7b8}�ʱ��"]
pub UpdateTime: TThostFtdcTimeType,
#[doc = "����\u{7b8}��"]
pub UpdateMillisec: TThostFtdcMillisecType,
#[doc = "�����һ"]
pub BidPrice1: TThostFtdcPriceType,
#[doc = "������һ"]
pub BidVolume1: TThostFtdcVolumeType,
#[doc = "������һ"]
pub AskPrice1: TThostFtdcPriceType,
#[doc = "������һ"]
pub AskVolume1: TThostFtdcVolumeType,
#[doc = "����۶�"]
pub BidPrice2: TThostFtdcPriceType,
#[doc = "��������"]
pub BidVolume2: TThostFtdcVolumeType,
#[doc = "�����۶�"]
pub AskPrice2: TThostFtdcPriceType,
#[doc = "��������"]
pub AskVolume2: TThostFtdcVolumeType,
#[doc = "�������"]
pub BidPrice3: TThostFtdcPriceType,
#[doc = "��������"]
pub BidVolume3: TThostFtdcVolumeType,
#[doc = "��������"]
pub AskPrice3: TThostFtdcPriceType,
#[doc = "��������"]
pub AskVolume3: TThostFtdcVolumeType,
#[doc = "�������"]
pub BidPrice4: TThostFtdcPriceType,
#[doc = "��������"]
pub BidVolume4: TThostFtdcVolumeType,
#[doc = "��������"]
pub AskPrice4: TThostFtdcPriceType,
#[doc = "��������"]
pub AskVolume4: TThostFtdcVolumeType,
#[doc = "�������"]
pub BidPrice5: TThostFtdcPriceType,
#[doc = "��������"]
pub BidVolume5: TThostFtdcVolumeType,
#[doc = "��������"]
pub AskPrice5: TThostFtdcPriceType,
#[doc = "��������"]
pub AskVolume5: TThostFtdcVolumeType,
#[doc = "���վ���"]
pub AveragePrice: TThostFtdcPriceType,
#[doc = "ҵ������"]
pub ActionDay: TThostFtdcDateType,
}
the header file encode with "GBK"
///深度行情
struct CThostFtdcDepthMarketDataField
{
///交易日
TThostFtdcDateType TradingDay;
///合约代码
TThostFtdcInstrumentIDType InstrumentID;
///交易所代码
TThostFtdcExchangeIDType ExchangeID;
///合约在交易所的代码
TThostFtdcExchangeInstIDType ExchangeInstID;
///最新价
TThostFtdcPriceType LastPrice;
///上次结算价
TThostFtdcPriceType PreSettlementPrice;
///昨收盘
TThostFtdcPriceType PreClosePrice;
///昨持仓量
TThostFtdcLargeVolumeType PreOpenInterest;
///今开盘
TThostFtdcPriceType OpenPrice;
///最高价
TThostFtdcPriceType HighestPrice;
///最低价
TThostFtdcPriceType LowestPrice;
///数量
TThostFtdcVolumeType Volume;
///成交金额
TThostFtdcMoneyType Turnover;
///持仓量
TThostFtdcLargeVolumeType OpenInterest;
///今收盘
TThostFtdcPriceType ClosePrice;
///本次结算价
TThostFtdcPriceType SettlementPrice;
///涨停板价
TThostFtdcPriceType UpperLimitPrice;
///跌停板价
TThostFtdcPriceType LowerLimitPrice;
///昨虚实度
TThostFtdcRatioType PreDelta;
///今虚实度
TThostFtdcRatioType CurrDelta;
///最后修改时间
TThostFtdcTimeType UpdateTime;
///最后修改毫秒
TThostFtdcMillisecType UpdateMillisec;
///申买价一
TThostFtdcPriceType BidPrice1;
///申买量一
TThostFtdcVolumeType BidVolume1;
///申卖价一
TThostFtdcPriceType AskPrice1;
///申卖量一
TThostFtdcVolumeType AskVolume1;
///申买价二
TThostFtdcPriceType BidPrice2;
///申买量二
TThostFtdcVolumeType BidVolume2;
///申卖价二
TThostFtdcPriceType AskPrice2;
///申卖量二
TThostFtdcVolumeType AskVolume2;
///申买价三
TThostFtdcPriceType BidPrice3;
///申买量三
TThostFtdcVolumeType BidVolume3;
///申卖价三
TThostFtdcPriceType AskPrice3;
///申卖量三
TThostFtdcVolumeType AskVolume3;
///申买价四
TThostFtdcPriceType BidPrice4;
///申买量四
TThostFtdcVolumeType BidVolume4;
///申卖价四
TThostFtdcPriceType AskPrice4;
///申卖量四
TThostFtdcVolumeType AskVolume4;
///申买价五
TThostFtdcPriceType BidPrice5;
///申买量五
TThostFtdcVolumeType BidVolume5;
///申卖价五
TThostFtdcPriceType AskPrice5;
///申卖量五
TThostFtdcVolumeType AskVolume5;
///当日均价
TThostFtdcPriceType AveragePrice;
///业务日期
TThostFtdcDateType ActionDay;
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests; it provides a GBK-encoded C++ header and garbled bindgen output as the reproduction. Start by locating bindgen's header-decoding entry point and any existing encoding-related tests, then determine the supported API and add coverage showing that the generated documentation preserves the source text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100